Ben Becker
- Forum-Beiträge: 209
23.07.2011, 00:42:05 via Website
23.07.2011 00:42:05 via Website
Hiho!
Ich versuche gerade den Android Lizenziserungs Service in meine App einzubauen und zwar so, dass der User wenn keine Lizenz übermittelt wird angeboten bekommt die App zu kaufen. Macht er das nicht kann er die App so nutzen wie die Free App.
Nur schließt sich die App immer wenn ich auf den "nicht kaufen" Button klicke. Hier mal mein Code. Was mache ich falsch? Oder hat Google da eine Sicherheitsfunktion eingebaut?
Edit: Nach einem Eclipse neustart gehts.
Ich versuche gerade den Android Lizenziserungs Service in meine App einzubauen und zwar so, dass der User wenn keine Lizenz übermittelt wird angeboten bekommt die App zu kaufen. Macht er das nicht kann er die App so nutzen wie die Free App.
Nur schließt sich die App immer wenn ich auf den "nicht kaufen" Button klicke. Hier mal mein Code. Was mache ich falsch? Oder hat Google da eine Sicherheitsfunktion eingebaut?
Edit: Nach einem Eclipse neustart gehts.
1public void dontAllow() {
2 Log.i("LICENSE", "dontAllow");
3 if (isFinishing()) {
4 // Don't update UI if Activity is finishing.
5 return;
6 }
7 displayResult(getString(R.string.dont_allow));
8 licensed = false;
9 // Should not allow access. In most cases, the app should assume
10 // the user has access unless it encounters this. If it does,
11 // the app should inform the user of their unlicensed ways
12 // and then either shut down the app or limit the user to a
13 // restricted set of features.
14 // In this example, we show a dialog that takes the user to Market.
15 checkingLicense = false;
16 didCheck = true;
17
18 showDialog(0);
19 }
20
21 public void applicationError(ApplicationErrorCode errorCode) {
22 Log.i("LICENSE", "error: " + errorCode);
23 if (isFinishing()) {
24 // Don't update UI if Activity is finishing.
25 return;
26 }
27 licensed = false;
28 // This is a polite way of saying the developer made a mistake
29 // while setting up or calling the license checker library.
30 // Please examine the error code and fix the error.
31 //String result = String.format(getString(R.string.application_error), errorCode);
32 checkingLicense = false;
33 didCheck = true;
34
35 //displayResult(result);
36 showDialog(0);
37 }
38 }
39
40 protected Dialog onCreateDialog(int id) {
41 // We have only one dialog.
42 return new AlertDialog.Builder(this)
43 .setTitle(R.string.unlicensed_dialog_title)
44 .setMessage(R.string.unlicensed_dialog_body)
45 .setPositiveButton(R.string.buy_button, new DialogInterface.OnClickListener() {
46 public void onClick(DialogInterface dialog, int which) {
47 Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
48 "http://market.android.com/details?id=" + getPackageName()));
49 startActivity(marketIntent);
50 finish();
51 }
52 })
53 .setNegativeButton(R.string.quit_button, new DialogInterface.OnClickListener() {
54 public void onClick(DialogInterface dialog, int which) {
55 System.out.println("WERBUNG anzeigen!");
56 }
57 })
58
59 .setCancelable(false)
60 .setOnKeyListener(new DialogInterface.OnKeyListener(){
61 public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
62 Log.i("License", "Key Listener");
63 finish();
64 return true;
65 }
66 })
67 .create();
68
69 }
2 Log.i("LICENSE", "dontAllow");
3 if (isFinishing()) {
4 // Don't update UI if Activity is finishing.
5 return;
6 }
7 displayResult(getString(R.string.dont_allow));
8 licensed = false;
9 // Should not allow access. In most cases, the app should assume
10 // the user has access unless it encounters this. If it does,
11 // the app should inform the user of their unlicensed ways
12 // and then either shut down the app or limit the user to a
13 // restricted set of features.
14 // In this example, we show a dialog that takes the user to Market.
15 checkingLicense = false;
16 didCheck = true;
17
18 showDialog(0);
19 }
20
21 public void applicationError(ApplicationErrorCode errorCode) {
22 Log.i("LICENSE", "error: " + errorCode);
23 if (isFinishing()) {
24 // Don't update UI if Activity is finishing.
25 return;
26 }
27 licensed = false;
28 // This is a polite way of saying the developer made a mistake
29 // while setting up or calling the license checker library.
30 // Please examine the error code and fix the error.
31 //String result = String.format(getString(R.string.application_error), errorCode);
32 checkingLicense = false;
33 didCheck = true;
34
35 //displayResult(result);
36 showDialog(0);
37 }
38 }
39
40 protected Dialog onCreateDialog(int id) {
41 // We have only one dialog.
42 return new AlertDialog.Builder(this)
43 .setTitle(R.string.unlicensed_dialog_title)
44 .setMessage(R.string.unlicensed_dialog_body)
45 .setPositiveButton(R.string.buy_button, new DialogInterface.OnClickListener() {
46 public void onClick(DialogInterface dialog, int which) {
47 Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
48 "http://market.android.com/details?id=" + getPackageName()));
49 startActivity(marketIntent);
50 finish();
51 }
52 })
53 .setNegativeButton(R.string.quit_button, new DialogInterface.OnClickListener() {
54 public void onClick(DialogInterface dialog, int which) {
55 System.out.println("WERBUNG anzeigen!");
56 }
57 })
58
59 .setCancelable(false)
60 .setOnKeyListener(new DialogInterface.OnKeyListener(){
61 public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
62 Log.i("License", "Key Listener");
63 finish();
64 return true;
65 }
66 })
67 .create();
68
69 }
— geändert am 23.07.2011, 00:44:01
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.