Monday, 29 August 2011

Install/Uninstall App from code

Hi ,
In this post i am going to tell you about how  to uninstall the app from the code.

INTENT FILTERS FOR SUCH THING  IS AS FOLLOWS:


<activity android:name=".PackageInstallerActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="content" />
        <data android:scheme="file" />
        <data android:mimeType="application/vnd.android.package-archive" />
    </intent-filter>
</activity>
 
<activity android:name=".UninstallerActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <action android:name="android.intent.action.DELETE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="package" />
    </intent-filter>
</activity>
 
  
FOR UNINSTALLING THE APP:

Uri packageURI = Uri.parse("package:com.android.name_of_your_app");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);
 

FOR  INSTALLING THE APP:(To install apk from your SD card)

String fileName = Environment.getExternalStorageDirectory() + "/name_of_your_app.apk";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
startActivity(intent);

 

1 comment:

  1. awesome sir..u r dng rght job by posting this kind f posts...i was searching it for last two months..u made my search complete today..

    Keep Posting...

    ReplyDelete

iOS Tutorial on Enumeration  So as we are talking about enumeration in iOS,the first thing comes into mind are Collections such as Array...