我在一个项目中有软键盘服务和设置活动。当软键盘运行时,设置活动是软键盘结束和启动。但是,我收到了日志。
日志是
07-03 11:15:08.969: E/AndroidRuntime(8340): FATAL EXCEPTION: main 07-03 11:15:08.969: E/AndroidRuntime(8340): java.lang.SecurityException: Not allowed to start service Intent { cmp=com.example.android.softkeyboard/.SoftKeyboard } without permission android.permission.BIND_INPUT_METHOD
07-03 11:15:08.969: E/AndroidRuntime(8340): at android.app.ContextImpl.startService(ContextImpl.java:836)
07-03 11:15:08.969: E/AndroidRuntime(8340): at android.content.ContextWrapper.startService(ContextWrapper.java:336)
07-03 11:15:08.969: E/AndroidRuntime(8340): at com.example.android.softkeyboard.MakeKeyActivity.SaveTotxt(MakeKeyActivity.java:213)
07-03 11:15:08.969: E/AndroidRuntime(8340): at com.example.android.softkeyboard.MakeKeyActivity.onOptionsItemSelected(MakeKeyActivity.java:144)
07-03 11:15:08.969: E/AndroidRuntime(8340): at android.app.Activity.onMenuItemSelected(Activity.java:2205)
07-03 11:15:08.969: E/AndroidRuntime(8340): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:749)
07-03 11:15:08.969: E/AndroidRuntime(8340): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
07-03 11:15:08.969: E/AndroidRuntime(8340): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:859)
07-03 11:15:08.969: E/AndroidRuntime(8340): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:581)
07-03 11:15:08.969: E/AndroidRuntime(8340): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:127)
07-03 11:15:08.969: E/AndroidRuntime(8340): at android.view.View$PerformClick.run(View.java:9099)
07-03 11:15:08.969: E/AndroidRuntime(8340): at android.os.Handler.handleCallback(Handler.java:587)
07-03 11:15:08.969: E/AndroidRuntime(8340): at android.os.Handler.dispatchMessage(Handler.java:92)
07-03 11:15:08.969: E/AndroidRuntime(8340): at android.os.Looper.loop(Looper.java:123)
07-03 11:15:08.969: E/AndroidRuntime(8340): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-03 11:15:08.969: E/AndroidRuntime(8340): at java.lang.reflect.Method.invokeNative(Native Method)
07-03 11:15:08.969: E/AndroidRuntime(8340): at java.lang.reflect.Method.invoke(Method.java:507)
07-03 11:15:08.969: E/AndroidRuntime(8340): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
07-03 11:15:08.969: E/AndroidRuntime(8340): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
07-03 11:15:08.969: E/AndroidRuntime(8340): at dalvik.system.NativeStart.main(Native Method)
我允许显化
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.softkeyboard">
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
<application android:label="aabbccdd">
<activity
android:name=".CustomKeyboardActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MakeKeyActivity"
android:label="@string/app_name">
</activity>
<activity
android:name=".MakeDictionaryActivity"
android:label="@string/app_name">
</activity>
<activity
android:name=".UpandDownActivity"
android:label="@string/app_name">
</activity>
<service
android:exported="true"
android:enabled="true"
android:name=".SoftKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im" android:resource="@xml/method" />
</service>
<uses-permission android:name="android.permission.BIND_INPUT_METHOD"/>
</application>
</manifest>
我称这个代码。
Intent intent=new Intent(this,SoftKeyboard.class);
stopService(intent);
startService(intent);
我给予了许可,但为什么要请求许可?