Have you tried Library which was provided with Android sdk? On Sat, Sep 15, 2012 at 2:57 PM, vinay kumar <vk872...@gmail.com> wrote:
> Have you tried which was provided with Android sdk? > > > On Sat, Sep 15, 2012 at 2:50 PM, janvi <jagruthi.bha...@gmail.com> wrote: > >> Any body who has already tried this help me out plz >> Its very urgent >> >> >> >> On Friday, September 14, 2012 5:32:02 PM UTC+5:30, janvi wrote: >>> >>> Dear All >>> >>> I need a favour,though it is old topic i need small info on how to go a >>> head with Android LVL >>> Plz reply me as soon as possible >>> The following is my sample code which I have written >>> >>> >>> package com.example.helloworld; >>> >>> import java.io.FileInputStream; >>> import java.io.FileNotFoundException; >>> import java.io.IOException; >>> import java.io.InputStream; >>> import java.security.KeyFactory; >>> import java.security.**NoSuchAlgorithmException; >>> import java.security.PublicKey; >>> import java.security.cert.**CertificateException; >>> import java.security.cert.**CertificateFactory; >>> import java.security.cert.**X509Certificate; >>> import java.security.interfaces.**RSAPublicKey; >>> import java.security.spec.**InvalidKeySpecException; >>> import java.security.spec.**PKCS8EncodedKeySpec; >>> >>> 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.os.Handler; >>> import android.provider.Settings.**Secure; >>> import android.view.View; >>> import android.view.Window; >>> import android.widget.Button; >>> import android.widget.TextView; >>> import android.widget.Toast; >>> >>> import com.google.android.vending.**licensing.AESObfuscator; >>> import com.google.android.vending.**licensing.LicenseChecker; >>> import com.google.android.vending.**licensing.**LicenseCheckerCallback; >>> import com.google.android.vending.**licensing.Policy; >>> import com.google.android.vending.**licensing.ServerManagedPolicy; >>> import com.google.android.vending.**licensing.util.Base64; >>> import com.google.android.vending.**licensing.util.** >>> Base64DecoderException; >>> >>> public class LicenseCheck extends Activity { >>> private static final String BASE64_PUBLIC_KEY = "Corresponding >>> Public Key"; >>> >>> // Generate your own 20 random bytes, and put them here. >>> private static final byte[] SALT = new byte[] { -46, 65, 30, -128, >>> -103, >>> -57, 74, -64, 51, 88, -95, -45, 77, -117, -36, -113, -11, >>> 32, -64, >>> 89 }; >>> >>> private TextView mStatusText; >>> private Button mCheckLicenseButton; >>> >>> private LicenseCheckerCallback mLicenseCheckerCallback; >>> private LicenseChecker mChecker; >>> // A handler on the UI thread. >>> private Handler mHandler; >>> >>> @Override >>> public void onCreate(Bundle savedInstanceState) { >>> super.onCreate(**savedInstanceState); >>> requestWindowFeature(Window.**FEATURE_INDETERMINATE_**PROGRESS); >>> setContentView(R.layout.**activity_main); >>> >>> mStatusText = (TextView) findViewById(R.id.status_text)**; >>> mCheckLicenseButton = (Button) findViewById(R.id.check_** >>> license_button); >>> mCheckLicenseButton.**setOnClickListener(new >>> View.OnClickListener() { >>> public void onClick(View view) { >>> doCheck(); >>> } >>> }); >>> >>> mHandler = new Handler(); >>> >>> // 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(); >>> } >>> >>> protected Dialog onCreateDialog(int id) { >>> final boolean bRetry = id == 1; >>> return new AlertDialog.Builder(this) >>> .setTitle(R.string.unlicensed_**dialog_title) >>> .setMessage( >>> bRetry ? R.string.unlicensed_dialog_**retry_body >>> : R.string.unlicensed_dialog_**body) >>> .setPositiveButton( >>> bRetry ? R.string.retry_button : >>> R.string.buy_button, >>> new DialogInterface.**OnClickListener() { >>> // bretry = 1 if retry button is active >>> >>> // bretry = 0 if buy button is active >>> >>> boolean mRetry = bRetry; >>> >>> public void onClick(DialogInterface dialog, >>> int which) { >>> if (mRetry) { >>> doCheck(); >>> } else { >>> Intent marketIntent = new Intent( >>> Intent.ACTION_VIEW, >>> Uri.parse("http://market.** >>> android.com/details?id= <http://market.android.com/details?id=>" >>> + getPackageName())); >>> startActivity(marketIntent); >>> } >>> } >>> }) >>> .setNegativeButton(R.string.**quit_button, >>> new DialogInterface.**OnClickListener() { >>> public void onClick(DialogInterface dialog, >>> int which) { >>> finish(); >>> } >>> }).create(); >>> } >>> >>> private void doCheck() { >>> mCheckLicenseButton.**setEnabled(false); >>> setProgressBarIndeterminateVis**ibility(true); >>> mStatusText.setText(R.string.**checking_license); >>> mChecker.checkAccess(**mLicenseCheckerCallback); >>> } >>> >>> private void displayResult(final String result) { >>> mHandler.post(new Runnable() { >>> public void run() { >>> mStatusText.setText(result); >>> setProgressBarIndeterminateVis**ibility(false); >>> mCheckLicenseButton.**setEnabled(true); >>> } >>> }); >>> } >>> >>> private void displayDialog(final boolean showRetry) { >>> mHandler.post(new Runnable() { >>> public void run() { >>> setProgressBarIndeterminateVis**ibility(false); >>> showDialog(showRetry ? 1 : 0); >>> mCheckLicenseButton.**setEnabled(true); >>> } >>> }); >>> } >>> >>> private class MyLicenseCheckerCallback implements >>> LicenseCheckerCallback { >>> public void allow(int policyReason) { >>> if (isFinishing()) { >>> // Don't update UI if Activity is finishing. >>> return; >>> } >>> // Should allow user access. >>> Intent i = new Intent(LicenseCheck.this, MainActivity.class); >>> startActivity(i); >>> // finish(); >>> >>> displayResult(getString(R.**string.allow)); >>> >>> } >>> >>> public void dontAllow(int policyReason) { >>> if (isFinishing()) { >>> // Don't update UI if Activity is finishing. >>> return; >>> } >>> displayResult(getString(R.**string.dont_allow)); >>> // 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. >>> // If the reason for the lack of license is that the service >>> is >>> // unavailable or there is another problem, we display a >>> // retry button on the dialog and a different message. >>> displayDialog(policyReason == Policy.RETRY); >>> } >>> >>> public void applicationError(int 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. >>> String result = String.format( >>> getString(R.string.**application_error), errorCode); >>> displayResult(result); >>> } >>> } >>> >>> @Override >>> protected void onDestroy() { >>> super.onDestroy(); >>> mChecker.onDestroy(); >>> } >>> >>> } >>> >>> >>> The following is my main activity >>> >>> >>> package com.example.helloworld; >>> >>> import android.os.Bundle; >>> import android.app.Activity; >>> import android.view.Menu; >>> >>> public class MainActivity extends Activity { >>> >>> @Override >>> public void onCreate(Bundle savedInstanceState) { >>> super.onCreate(**savedInstanceState); >>> setContentView(R.layout.**activity_main); >>> } >>> >>> @Override >>> public boolean onCreateOptionsMenu(Menu menu) { >>> getMenuInflater().inflate(R.**menu.activity_main, menu); >>> return true; >>> } >>> } >>> >>> >>> >>> The following is my activity_main.xml >>> >>> >>> <LinearLayout xmlns:android="http://schemas.** >>> android.com/apk/res/android <http://schemas.android.com/apk/res/android> >>> " >>> android:orientation="vertical" >>> android:layout_width="fill_**parent" >>> android:layout_height="fill_**parent" >>> > >>> <TextView >>> android:id="@+id/status_text" >>> android:layout_width="fill_**parent" >>> android:layout_height="0dip" >>> android:layout_weight="1" >>> /> >>> <Button >>> android:id="@+id/check_**license_button" >>> android:layout_width="fill_**parent" >>> android:layout_height="wrap_**content" >>> android:text="@string/check_**license" >>> /> >>> </LinearLayout> >>> >>> I have also added the following tag in the manifest >>> >>> <uses-permission android:name="com.android.**vending.CHECK_LICENSE" /> >>> >>> >>> When iam executing this iam getting the following errors >>> >>> 1.error contacting licensing server android >>> 2.ERROR_NOT_MARKET_MANAGED >>> >>> Iam testing it by using a test account which is added in the edit >>> profile page of google publisher account and in this process iam facing the >>> above errors >>> >>> I have the following doubts >>> >>> 1.Whether is it necessary to upload and save the APP in the google >>> publisher account if we want to test it using test account >>> 2.How actually to start with the testing process >>> >>> >>> Thanks in advance >>> >>> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en