0

由于我是我公司提供的用户手机的管理员,我需要限制用户打开设置。我想创建一个服务来检测设置何时被打开。但是我在服务代码和清单 xml 中找不到需要监控的意图?

例如,

IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_CHANGED);
this.registerReceiver(mBroadcastReceiver, filter);


<intent-filter>
            <action android:name="android.intent.action.TIMT_SET"/> 
</intent-filter>

以上是我在网上搜索的示例,但我不知道哪个意图代表 SETTINGS。

4

3 回答 3

2

由于我是我公司提供的用户手机的管理员,我需要限制用户打开设置。

创建您自己的 Android 操作系统自定义版本,锁定设置应用程序,将该自定义版本打包到您自己的自定义 ROM 模块中,然后在您分发的设备上安装该 ROM 模块。

于 2012-08-31T13:00:38.917 回答
1

I know of 2 ways wich both have their (dis-)advanteges.

1) You can detect if your app is going to the background which happens when the user opens the menu. The handler is:

public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);

There you can close ALL system menus, even the menu to reboot or turn off the device! This is done with this intent:

Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);

2) You can start a run a service with a background worker that is checking the front app very often (like twice a second). You can get the foreground app like this:

String packageName;
String className;
ActivityManager amen = (ActivityManager)getBaseContext().getSystemService(Activity.ACTIVITY_SERVICE);
packageName = amen.getRunningTasks(1).get(0).topActivity.getPackageName();
className = amen.getRunningTasks(1).get(0).topActivity.getClassName();

The package name for the settings is: com.android.settings

If you detect it you can simply start an intent that brings your app back to the foreground.

Hope it helps :)

于 2013-06-24T11:19:58.227 回答
-1

写一个Service读系统LogCat,当一个应用程序启动时,它会显示一个非常独特的日志。例如,这是启动Gmail应用程序时的日志。

08-31 16:42:28.650: I/ActivityManager(3905): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.google.android.gm/.ConversationListActivityGmail bnds=[240,384][360,534]} from pid 7290

好吧,对于您的情况,只需比较cmp=if it equals com.android.settings,然后做您需要做的事情。

于 2012-08-31T09:44:47.383 回答