[英]How to start an activity from application in one device to the application in another device
[英]How to prevent another package/activity from running on the device through my application?
我有一個具有系統權限的應用程序。 當設備在重啟后啟動時,我的應用程序會顯示一個 UI。 問題是,另一個活動(不是我的應用程序的一部分)也啟動了,因此支持我的活動。
//my activity starts
ActivityManager: START u0 {flg=0x10000000 cmp=com.company.myApp/.activities.MyActivity} from uid 10097 on display 0
..... stuff happening -> UI is being updated
// some other activity starts (automatically)
ActivityManager: START u0 {act=com.company.someOtherApp.Presentation.APL_RenderDocument flg=0x18000000 pkg=com.company.test cmp=com.company.test/.SomeOtherActivity (has extras)} from uid 10082 on display 0
// my activity goes into background.
MyActivity: onPause()
MyActivity: onStop()
有沒有辦法阻止創建(或運行)這個其他應用程序?
我正在研究兩種特殊方法
setComponentEnabledSetting()
為 package 組件(活動、接收器、服務、提供者)設置啟用設置。 此設置將覆蓋任何已啟用的 state,它可能已由組件在其清單中設置。
setApplicationEnabledSetting()
為應用程序設置啟用設置此設置將覆蓋任何已啟用的 state,它可能已由應用程序在其清單中設置。 它還會覆蓋清單中為任何應用程序組件啟用的 state 集。 它不會覆蓋由 setComponentEnabledSetting(ComponentName, int, int) 為應用程序的任何組件設置的任何已啟用 state。
我不太明白這些方法是否可以實現我想要實現的目標的區別。
如果包/應用程序的“啟用設置”/“啟用狀態”設置為禁用,是否意味着應用程序或 package 永遠不會被調用?
還有另一種方法嗎?
據我所知有兩種方法
一個是kill進程
Process.killProcess( APP-PROCESS-ID )
或者你可以用活動管理器殺死后台進程
ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
am.killBackgroundProcesses(packageName);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.