外部调用关机API时,会发送类似于下面的intent:
Intent newIntent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
newIntent.putExtra(Intent.EXTRA_KEY_CONFIRM,false);
startActivity(newIntent);
而响应的地方,是一个无界面的activity,其类是framework下面的com.android.server.ShutdownActivity.
其配置的xml如下所示:
<activity android:name="com.android.server.ShutdownActivity"
android:permission="android.permission.SHUTDOWN"
android:configChanges="orientation|keyboardHidden|navigation|mcc|mnc|locale|touchscreen|fontScale|keyboard"
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.ACTION_REQUEST_SHUTDOWN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

本文介绍了Android中外部调用关机API的工作原理。通过发送特定Intent实现设备关机操作,并详细展示了无界面Activity——ShutdownActivity的配置方式及其如何响应ACTION_REQUEST_SHUTDOWN动作。
1913

被折叠的 条评论
为什么被折叠?



