我需要一些帮助。简而言之。我安装了通用许可证检查代码,但是当我将我的应用程序上传到市场时,它不允许用户使用我的应用程序。它告诉他们他们没有许可可以有人告诉我我错过了什么吗?
package com.test.test;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.widget.Toast;
import com.manifestxml.chakra.AESObfuscator;
import com.manifestxml.chakra.LicenseChecker;
import com.manifestxml.chakra.LicenseCheckerCallback;
import com.manifestxml.chakra.ServerManagedPolicy;
public class splash extends Activity {
private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
public void allow() {
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
// Should allow user access.
startMainActivity();
}
public void applicationError(ApplicationErrorCode errorCode) {
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
// This is a polite way of saying the developer made a mistake
// while setting up or calling the license checker library.
// Please examine the error code and fix the error.
toast("Error: " + errorCode.name());
startMainActivity();
}
public void dontAllow() {
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
// Should not allow access. In most cases, the app should assume
// the user has access unless it encounters this. If it does,
// the app should inform the user of their unlicensed ways
// and then either shut down the app or limit the user to a
// restricted set of features.
// In this example, we show a dialog that takes the user to Market.
showDialog(0);
}
}
private static final String BASE64_PUBLIC_KEY = "my key... sorry you cant see it";
private static final byte[] SALT = new byte[] { salt numbers here };
private LicenseChecker mChecker;
// A handler on the UI thread.
private LicenseCheckerCallback mLicenseCheckerCallback;
private void doCheck() {
mChecker.checkAccess(mLicenseCheckerCallback);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Try to use more data here. ANDROID_ID is a single point of attack.
String deviceId = Secure.getString(getContentResolver(),
Secure.ANDROID_ID);
// Library calls this when it's done.
mLicenseCheckerCallback = new MyLicenseCheckerCallback();
// Construct the LicenseChecker with a policy.
mChecker = new LicenseChecker(this, new ServerManagedPolicy(this,
new AESObfuscator(SALT, getPackageName(), deviceId)),
BASE64_PUBLIC_KEY);
doCheck();
}
@Override
protected Dialog onCreateDialog(int id) {
// We have only one dialog.
return new AlertDialog.Builder(this)
.setTitle("Application Not Licensed")
.setCancelable(false)
.setMessage(
"This app does not appear to be valid.
Please purchase it from Android Market. If this is an error, please contact the
developer for a correction.")
.setPositiveButton("Purchase",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
Intent marketIntent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://market.android.com/details?id="
+
getPackageName()));
startActivity(marketIntent);
finish();
}
})
.setNegativeButton("Exit",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
finish();
}
}).create();
}
@Override
protected void onDestroy() {
super.onDestroy();
mChecker.onDestroy();
}
private void startMainActivity() {
startActivity(new Intent(this, ToggleButtonMain.class)); //REPLACE
MainActivity.class WITH YOUR
APPS ORIGINAL LAUNCH ACTIVITY
finish();
}
public void toast(String string) {
Toast.makeText(this, string, Toast.LENGTH_SHORT).show();
}
}
这是我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.name"
android:versionName="1.6" android:versionCode="9">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".splash" android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name = ".ToggleButtonMain">
</activity>
<activity android:label="@string/app_name"
android:name=".TimerActivity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:label="Preferences" android:name=".TimerPrefActivity">
<intent-filter>
<action android:name="android.intent.action.CATEGORY_PREFERENCE" />
</intent-filter>
</activity>
<activity android:name = ".TabBarExample">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name = "meditationmusic">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".FirstTab" />
<activity android:name=".SecondTab" />
<activity android:name=".thirdTab" />
<activity android:name=".fourthTab" />
<activity android:name=".fifthTab" />
<activity android:name=".sixthTab" />
<activity android:name=".seventhTab" />
<activity android:name=".HowToOpen" />
<activity android:name=".viztech" />
<activity android:name=".viznotes" />
<activity android:name=".cleanchakra" />
<activity android:name=".breathing" />
<activity android:name=".benefits" />
<receiver android:name=".TimerReceiver" ></receiver>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.android.vending.CHECK_LICENSE"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
</manifest>
有人可以帮忙吗?......我忽略了什么......提前谢谢。
答案 0 :(得分:0)
您确定BASE64_PUBLIC_KEY与market.android.com/publish上的内容完全匹配(点击编辑个人资料即可到达)吗?