inputmethodservice.java,java.lang.SecurityException异常:未经允许android.permission.BIND_INPUT_METHOD只为<...

I have this very unpeculiar exception.The thing is have i have this app that has a button to start

InputMethodService

that starts like this

public class MyGroovyIme extends InputMethodService {

and this is how it looks in manifest.

android:name=".MyGroovyIme"

android:enabled="true"

android:exported="true"

android:permission="android.permission.BIND_INPUT_METHOD" >

android:name="android.view.im"

android:resource="@xml/method" />

and this is how I start service

void startServer() {

Log.v(TAG, "Starting service...");

Intent serviceIntent = new Intent(this, MyGroovyIme.class);

startService(serviceIntent);

Log.v(TAG, "Starting service...success!!!");

// this.finish();

Log.v(TAG, "finish called...");

}

the whole setup works like a charm when i do it on Tablet(Moto XOOM ,its 3.2) but when I do it on Devices that run on 2.2 and 2.1(i havent tried it on 2.3 and cant use emulator either) this is what i get

java.lang.SecurityException: Not allowed to start service Intent { cmp=com.spp.ime.demo/.MyGroovyIme } without permission android.permission.BIND_INPUT_METHOD

at android.app.ContextImpl.startService(ContextImpl.java:840)

at android.content.ContextWrapper.startService(ContextWrapper.java:336)

at com.spp.ime.demo.GROOVY_IME_DEMOActivity.startServer(GROOVY_IME_DEMOActivity.java:137)

at com.spp.ime.demo.GROOVY_IME_DEMOActivity.onStartClick(GROOVY_IME_DEMOActivity.java:104)

at com.spp.ime.demo.GROOVY_IME_DEMOActivity.onClick(GROOVY_IME_DEMOActivity.java:67)

at android.view.View.performClick(View.java:2408)

at android.view.View$PerformClick.run(View.java:8816)

at android.os.Handler.handleCallback(Handler.java:587)

at android.os.Handler.dispatchMessage(Handler.java:92)

at android.os.Looper.loop(Looper.java:123)

at android.app.ActivityThread.main(ActivityThread.java:4633)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:521)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

at dalvik.system.NativeStart.main(Native Method)

I do understand the security concerns but shouldnt it be same for all devices or am i missing something specific to versions <3.2

解决方案

After a long search have not found a reliable answer and still have not got the exact reason..

but going through the new features have found hardware features that were added at later versions may have led to this leniency in Android OS.

Here is the link describing major updates for Android here

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值