0

Here is my question,

  • I need to redirect the user to specific app page (Google play page) from Page_One.Java. (Implemented)
  • The user successfully install that application from Google Play page, now it returns to previous page.(Implemented)
  • Now i need to get the response in Page_One.java, whether the app installation is success or failed. Is it possible to get the installation status?
Aerrow
  • 12,086
  • 10
  • 56
  • 90

2 Answers2

2

You can check with the PackageManager if the application has been installed or not.

HERE you can find a working code that helps to find out if the application is properly installed or not.

Community
  • 1
  • 1
StarsSky
  • 6,721
  • 6
  • 38
  • 63
1

You can register a broadcast receiver detecting a package added action like this :

<receiver android:name="com.example.InstalledReceiver" >
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_ADDED" />
        <data android:scheme="package" />
    </intent-filter>
</receiver>

Then declare a broadcast receiver class

public class InstalledReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String installedPackage = intent.getDataString();
        //Uri like package://com.example.myapp
    }
}

In the onReceive method you will know if it was the correct application. However I am not sure if you can get the status on failure

TheCopycat
  • 401
  • 2
  • 6
  • may i know we can't use startActivityForResult(); instead of startActivity(); – Aerrow Feb 01 '14 at 11:27
  • startActivityForResult requires the Activity you are calling to manually set a result. I am not sure on how you call the Google Play Page (maybe with the standard `android.action.VIEW` ) but I don't think it will return a result. – TheCopycat Feb 01 '14 at 12:30
  • I called the market like this, Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(marketIntent); – Aerrow Feb 01 '14 at 12:34
  • That is what I thought. I believe, after reading your question once again that the answer provided by StarsSky is the most suitable with your needs. – TheCopycat Feb 01 '14 at 12:46