2011-12-15 37 views
0

我需要一點幫助。爲了做到這一點。我安裝了通用許可證檢查代碼,但是當我將我的應用程序上傳到市場時,它不允許用戶使用我的應用程序。這是告訴他們,他們沒有權限,有人可以告訴我我錯過了什麼?安卓許可證不能正常工作

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

你自己重新創建了錯誤嗎? – ethan 2011-12-15 19:13:06

+0

我上傳之前一切似乎都很好..我想我可以再次運行這些文件..它不會受到傷害。但是,我的代碼有問題,我忽略了什麼? – user474026 2011-12-15 20:26:47

回答

0

您確定BASE64_PUBLIC_KEY與market.android.com/publish上的內容完全匹配(點擊編輯個人資料以獲取該內容)嗎?