Skip to content Skip to sidebar Skip to footer

Launch An Application Programmatically After Installation In Android

I have developed an application(Test)such that whenever the application has updates with the latest version it will download and install the latest .apk file. Now I want the latest

Solution 1:

Android throws broadcast on installing app . You could receive it in receiver and launch from there.

<receiverandroid:name="com.your.receiver"android:enabled="true"android:exported="true" ><intent-filter><actionandroid:name="android.intent.action.PACKAGE_ADDED" /><actionandroid:name="android.intent.action.PACKAGE_REMOVED" /><dataandroid:scheme="package"/></intent-filter></receiver><uses-permissionandroid:name="android.permission.BROADCAST_PACKAGE_REMOVED" />

In receiver add this :

@OverridepublicvoidonReceive(Context context, Intent intent) {
        //start activityIntenti=newIntent();
        i.setClassName("com.pkg", "com.pkg.yourStartActivity");
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }

Solution 2:

This is the intent filter you have to set for your broadCastReceiver

<receiverandroid:name="com.your.receiver"><intent-filter><actionandroid:name="android.intent.action.MY_PACKAGE_REPLACED"/></intent-filter></receiver>

Post a Comment for "Launch An Application Programmatically After Installation In Android"