English 中文(简体)
LVL 来自Intent Service的许可检查
原标题:LVL license check from Intent Service

我有一份自由信,其中还载有一种功能,如果用户在安康市场购买我用的钥匙,即可使用。 我在主食中设立了一个接收器和另一个接收器。 当用户在主机中点击“Validate key”纽顿时,用钥匙电机向接收人播放了意向书,然后向Intent Service开火,以检查是否具有重要许可。 随后,Intent Service向主要接收器播放了从LVL检查中除去的“答复”的意向书。

我几乎在那里。 只有当我试图在Intent Service中进行LVL检查时,我才发现一个错误:

W/MessageQueue(2652): java.lang.RuntimeException: Handler{4052de20} sending message to a Handler on a dead thread
W/MessageQueue(2773):   at com.android.vending.licensing.LicenseChecker$ResultListener.verifyLicense(LicenseChecker.java:207)

任何建议?

The Intentservice sources:

public class CheckerService extends IntentService {

private static final byte[] SALT = ....;
private static final String BASE64_PUBLIC_KEY = ...;
private String device_id;

public CheckerService() {
    super("CheckerService");
}

@Override
protected void onHandleIntent(Intent intent) {
    SharedPreferences data = getSharedPreferences("data", MODE_PRIVATE);
    device_id = data.getString("device_id", null);

    if (device_id == null) {
        SharedPreferences.Editor editor = data.edit();
        device_id = new DeviceId().generate(this);
        editor.putString("device_id", device_id);
        editor.commit();
    }

    ServerManagedPolicy smp = new ServerManagedPolicy(this,
            new AESObfuscator(SALT, getPackageName(), device_id));
    LicenseChecker checker = new LicenseChecker(this, smp, BASE64_PUBLIC_KEY);
    checker.checkAccess(new LicenseCheckerCallback(){

        public void allow() {
            Intent i = new Intent();                
            i.setAction("com.mainapp.intent.action.LICENSE_RESPONSE");
            i.putExtra("response", "LICENSE_OK");
            sendBroadcast(i);
        }

        public void dontAllow() {
            Intent i = new Intent();                
            i.setAction("com.mainapp.intent.action.LICENSE_RESPONSE");
            i.putExtra("response", "LICENSE_NOT_OK");
            sendBroadcast(i);
        }

        public void applicationError(ApplicationErrorCode errorCode) {
            Intent i = new Intent();                
            i.setAction("com.mainapp.intent.action.LICENSE_RESPONSE");
            i.putExtra("response", "LICENSE_ERROR");
            sendBroadcast(i);
        }});

}


@Override
public void onDestroy() {
    super.onDestroy();
    checker.onDestroy();
}
}
问题回答

我认为,这个问题在于公务员。 公务员管理自己的生命周期。 基本上,这只是一个非倡议的线索。 这项服务在接获之前就被销毁,因此,当追捕没有发生时,便无法追捕。

您可以尝试以《裁武条约》为服务。 科技研所或《第一阶段裁武条约》管理生命周期。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签