Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some input files use or override a deprecated API. #719

Closed
sharkguto opened this issue Apr 20, 2016 · 1 comment
Closed

Some input files use or override a deprecated API. #719

sharkguto opened this issue Apr 20, 2016 · 1 comment

Comments

@sharkguto
Copy link

Whenever i try to build i got error on Notification, that was deprecated.

This is the bug:

[javac] notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
[javac] ^
[javac] symbol: method setLatestEventInfo(Context,String,String,PendingIntent)
[javac] location: variable notification of type Notification
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 1 error
BUILD FAILED

I found that some people have the same issue as me:

https://groups.google.com/forum/#!searchin/kivy-users/override$20a$20deprecated$20API./kivy-users/mf_t1ANrT40/zVC_DRn1AQAJ

I finally figure out how to fix it.... I do not know if it is the best way, but help me to put admob on my kivy app.

Possible solution:

image

`package org.renpy.android;

import android.app.Service;
import android.os.IBinder;
import android.os.Bundle;
import android.content.Intent;
import android.content.Context;
import android.util.Log;
import android.app.Notification;
//import android.app.NotificationCompat;
//import android.support.v4.util;
import android.app.PendingIntent;
import android.os.Process;

public class PythonService extends Service implements Runnable {

// Thread for Python code
private Thread pythonThread = null;

// Python environment variables
private String androidPrivate;
private String androidArgument;
private String pythonHome;
private String pythonPath;
// Argument to pass to Python code,
private String pythonServiceArgument;
public static Service mService = null;

@Override
public IBinder onBind(Intent arg0) {
    return null;
}

@Override
public void onCreate() {
    super.onCreate();
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (pythonThread != null) {
        Log.v("python service", "service exists, do not start again");
        return START_NOT_STICKY;
    }

    Bundle extras = intent.getExtras();
    androidPrivate = extras.getString("androidPrivate");
    // service code is located in service subdir
    androidArgument = extras.getString("androidArgument") + "/service";
    pythonHome = extras.getString("pythonHome");
    pythonPath = extras.getString("pythonPath");
    pythonServiceArgument = extras.getString("pythonServiceArgument");
    String serviceTitle = extras.getString("serviceTitle");
    String serviceDescription = extras.getString("serviceDescription");

    pythonThread = new Thread(this);
    pythonThread.start();

    Context context = getApplicationContext();
    Intent contextIntent = new Intent(context, PythonActivity.class);
    PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    Notification notification = new Notification.Builder(context)
     .setContentTitle(serviceTitle)
     .setContentText(serviceDescription)
     .setSmallIcon(context.getApplicationInfo().icon)
     .build();


    /*
     * notification = builder.setContentIntent(contextIntent)
                  .setSmallIcon(context.getApplicationInfo().icon).setTicker(text).setWhen(System.currentTimeMillis())
                  .setAutoCancel(true).setContentTitle(serviceTitle)
                  .setContentText(serviceDescription).build();

    Notification notification = new Notification(context.getApplicationInfo().icon,
            serviceTitle,
            System.currentTimeMillis());
    notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);*/

    startForeground(1, notification);

    return START_NOT_STICKY;
}

@Override
public void onDestroy() {
    super.onDestroy();
    pythonThread = null;
    Process.killProcess(Process.myPid());
}

@Override
public void run(){

    // libraries loading, the same way PythonActivity.run() do
    System.loadLibrary("sdl");
    System.loadLibrary("sdl_image");
    System.loadLibrary("sdl_ttf");
    System.loadLibrary("sdl_mixer");
    System.loadLibrary("python2.7");
    System.loadLibrary("application");
    System.loadLibrary("sdl_main");


    System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_io.so");
    System.load(getFilesDir() + "/lib/python2.7/lib-dynload/unicodedata.so");

    try {
        System.loadLibrary("ctypes");
        System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_ctypes.so");
    } catch(UnsatisfiedLinkError e) {
    }

    try {
        System.loadLibrary("sqlite3");
        System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_sqlite3.so");
    } catch(UnsatisfiedLinkError e) {
    }

    try {
        System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imaging.so");
        System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingft.so");
        System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingmath.so");
    } catch(UnsatisfiedLinkError e) {
    }

    this.mService = this;
    nativeInitJavaEnv();
    nativeStart(androidPrivate, androidArgument, pythonHome, pythonPath,
            pythonServiceArgument);
}

// Native part
public static native void nativeStart(String androidPrivate, String androidArgument,
        String pythonHome, String pythonPath,
        String pythonServiceArgument);

public static native void nativeInitJavaEnv();

}
`

@kived
Copy link
Contributor

kived commented Apr 20, 2016

That's not an error. It says right there that it is a Note. Based on the very very limited output you provided, I can see that the error is above that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants