Created
October 4, 2014 08:13
-
-
Save operando/ef173040a421e1fd41ba to your computer and use it in GitHub Desktop.
【Android】悪用厳禁!アンインストールのIntentについて ref: http://qiita.com/operandoOS/items/dda8bb3b7677250af9ee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// String packageName = アンインストールするアプリのPackage名 | |
Uri uri = Uri.fromParts("package", packageName, null); | |
Intent intent = new Intent(Intent.ACTION_DELETE, uri); | |
context.startActivity(intent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<activity android:name=".UninstallerActivity" | |
android:configChanges="orientation|keyboardHidden|screenSize" | |
android:excludeFromRecents="true" | |
android:theme="@android:style/Theme.DeviceDefault.Dialog.NoActionBar"> | |
<intent-filter> | |
<action android:name="android.intent.action.DELETE" /> | |
<action android:name="android.intent.action.UNINSTALL_PACKAGE" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
<data android:scheme="package" /> | |
</intent-filter> | |
</activity> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// String packageName = アンインストールするアプリのPackage名 | |
// requestCode = 1 | |
Uri uri = Uri.fromParts("package", packageName, null); | |
Intent intent = new Intent(Intent.ACTION_DELETE, uri); | |
activity.startActivityForResult(intent, requestCode); | |
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
Log.d("onActivityResult", "requestCode : " + requestCode); | |
Log.d("onActivityResult", "resultCode : " + (RESULT_OK == resultCode)); | |
Log.d("onActivityResult", "resultCode : " + resultCode); | |
Log.d("onActivityResult", "onActivityResult"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D/onActivityResult(24263): requestCode : 1 | |
D/onActivityResult(24263): resultCode : false | |
D/onActivityResult(24263): resultCode : 0 | |
// resultCode = 0 = RESULT_CANCELED?? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment