从其他android应用程序更改活动
我想阻止某些程序的开放 示例:我有一个包含所有配置的程序(a)(一把钥匙,要锁定的程序列表) 当激活时(A),你打开一个程序(B)(android菜单中的短屏幕),如果它在锁定程序列表中,而不是打开它,那么应该首先打开(A)。我的目的是询问我的钥匙(A)是否允许,然后预定的程序(B)打开 示例程序 提示:应用程序(A)如何看到正在打开的程序(B)并用我的意图或片段替换它从其他android应用程序更改活动,android,android-intent,intentservice,oncreate,Android,Android Intent,Intentservice,Oncreate,我想阻止某些程序的开放 示例:我有一个包含所有配置的程序(a)(一把钥匙,要锁定的程序列表) 当激活时(A),你打开一个程序(B)(android菜单中的短屏幕),如果它在锁定程序列表中,而不是打开它,那么应该首先打开(A)。我的目的是询问我的钥匙(A)是否允许,然后预定的程序(B)打开 示例程序 提示:应用程序(A)如何看到正在打开的程序(B)并用我的意图或片段替换它 抱歉我的英语不好。我通过服务解决了这个问题 public class RepeatClass extends Serv
抱歉我的英语不好。我通过服务解决了这个问题
public class RepeatClass extends Service {
private static final String TAG = "ServiceTag";
private boolean isRunning = false;
@Override
public void onCreate() {
Log.i(TAG, "Service onCreate");
isRunning = true;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "Service onStartCommand");
//Creating new thread for my service
//Always write your long running tasks in a separate thread, to avoid ANR
new Thread(new Runnable() {
@Override
public void run() {
//Your logic that service will perform will be placed here
//In this example we are just looping and waits for 1000 milliseconds in each loop.
while (true) {try {
Thread.sleep(1000);
//Detect openning programm with activeManager and open normal intent
}
catch(Exception e){
}
}
}
}