File tree Expand file tree Collapse file tree 2 files changed +3
-1
lines changed
sample/src/main/java/com/xdandroid/sample/misc Expand file tree Collapse file tree 2 files changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,15 @@ protected void onCreate(Bundle savedInstanceState) {
18
18
if (Build .VERSION .SDK_INT < Build .VERSION_CODES .N ) return ;
19
19
new Thread (() -> {
20
20
try {
21
- ActivityManager am = getSystemService ( ActivityManager . class );
21
+ String thisApp = getPackageName ( );
22
22
Method m = ActivityManager .class .getMethod ("forceStopPackage" , String .class );
23
+ ActivityManager am = getSystemService (ActivityManager .class );
23
24
getPackageManager ().getInstalledPackages (0 )
24
25
.stream ()
25
26
.filter (i -> (i .applicationInfo .flags & ApplicationInfo .FLAG_SYSTEM ) == 0 )
26
27
.filter (i -> (i .applicationInfo .flags & ApplicationInfo .FLAG_UPDATED_SYSTEM_APP ) == 0 )
27
28
.map (i -> i .packageName )
29
+ .filter (n -> !thisApp .equals (n ))
28
30
.forEach (n -> {
29
31
try { m .invoke (am , n ); } catch (Exception e ) { e .printStackTrace (); }
30
32
});
You can’t perform that action at this time.
0 commit comments