Using Market Intents
However in order to use these intents within your app the user also has to have the app with the intent installed on their device. If the user doesn't have the app installed you want to automatically point them to the apps that they require, i.e. open up the Android Market at the right page ready for them to install it. The user can then install the required app and perform a back action to return to your app. This can be achieved with a simple piece of code.
Lets say for example you want to incorporate barcode scanning within your app. You could utilise ZXing. So within the method where you are trying to access the intent (i.e. scan a barcode) you can add code like this:-
1: try
2: {
3: Intent newIntent = new Intent("com.google.zxing.client.android.SCAN");
4: startActivityForResult(newIntent, BARCODE_SCAN );
5: }
6: catch (Exception e)
7: {
8: String zxingUrl = "market://details?id=com.google.zxing.client.android";
9: Intent intent = new Intent(Intent.ACTION_VIEW,
10: Uri.parse(zxingUrl));
11:
12: intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
13: startActivity(intent);
14: }
The FLAG_ACTIVITY_NO_HISTORY value stops the marketplace from being kept on the history stack. so as soon as the user navigates away from it the marketplace is killed and the user will be returned to your app.
Helpful Android information for developers
Check out -
Android Blog Spot - provides project's news, tips and tricks and development examples.









