我已经成功实施了google play ....并且其工作正常.....但是当我在使用后关闭我的应用程序...并且在关闭应用程序几分钟后...错误被给予“应用程序已经突然停止“.....在log cat中它给出了错误在BillingService.java
10-10 13:38:38.739:E / AndroidRuntime(3586):引起:java.lang.NullPointerException
10-10 13:38:38.739:E / AndroidRuntime(3586):at。 BillingService.handleCommand(BillingService.java:372)
10-10 13:38:38.739:E / AndroidRuntime(3586):at。 BillingService.onStart(BillingService.java:362)
10-10 13:38:38.739:E / AndroidRuntime(3586):在android.app.Service.onStartCommand(Service.java:438)
我的代码是......
public void onStart(Intent intent, int startId) {
handleCommand(intent, startId);------>362
}
public void handleCommand(Intent intent, int startId) {
String action = intent.getAction();------>line 732
if (Consts.DEBUG) {
Log.i(TAG, "handleCommand() action: " + action);
}
}
答案 0 :(得分:2)
我认为您必须完全退出该应用程序。退出应用程序后,检查任务管理器,如果它仍然在正在运行的应用程序部分中,则必须结束该过程。
您可以查看以下代码:
// This you have to insert inside the exit button click event
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
onQuitPressed();
//This is the onQuitPressed method
//to remove application from task manager
public void onQuitPressed() {
int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);
}