gpt4 book ai didi

android - java.lang.SecurityException : Not allowed to start service Intent without permission BIND_INPUT_SERVICE 错误

转载 作者:行者123 更新时间:2023-11-29 21:19:38 26 4
gpt4 key购买 nike

Hi I am working on soft keyboard.

I am getting exception of permission when I am accessing my service class from my simple activity class.

Stack Trace of exception is shown below,

enter image description here

In above image InputServiceMethod class = Underlined by Green color.

Activity class = Underlined by Blue color.

I am getting this exception when I am calling InputServiceMethod class from activity class.

For this I used the below code which gives me exception,

Intent intent = new Intent(v.getContext(),SoftKeyboard.class);
startService(intent);
finish();

My manifest file as shown below,

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.softkeyboard"
android:installLocation="preferExternal">

<uses-permission android:name="android.permission.VIBRATE" />

<!-- <permission android:name="android.permission.BIND_INPUT_SERVICE" -->
<!-- android:exported="true"></permission> -->

<application android:label="@string/ime_name">
<service
android:name="com.example.android.softkeyboard.SoftKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD"
android:exported="true">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>

<meta-data
android:name="android.view.im"
android:resource="@xml/method" />
</service>

<activity
android:name="com.configuration.Configuration"
android:label="@string/title_activity_configuration" >
</activity>
</application>

我不明白,即使我授予关于 BIND_INPUT_METHOD 的权限,它也会抛出异常。

如何解决?谢谢

最佳答案

看起来您正在将服务绑定(bind)到操作 android.view.InputMethod 而它受到权限 android.permission.BIND_INPUT_METHOD 的保护,该权限用于确保只有系统可以通过其保护级别绑定(bind)到它。所以根据Android你只能定义键盘处理服务而不能显式调用它,它会在需要输入法时由系统自动调用。所以有两种方法可以解决:1.让它被系统调用,不要显式调用,或者2. 使用您正在运行的系统签名签署您的应用程序,这使得您的应用程序平台依赖。 (如果您正在构建通用应用程序,则不建议这样做)。

希望您了解情况。

关于android - java.lang.SecurityException : Not allowed to start service Intent without permission BIND_INPUT_SERVICE 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20902480/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com