当我运行我的应用程序时,我得到了这个错误。我还在manifest.xml中包含了对surfaceFlinger的权限
"uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"但它仍然在LogCat中给出了相同的错误" can't access the SurfaceFlinger"。
基本上,我想在开发工具中运行开发设置代码。
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
try {
Class partypes[] = new Class[1];
partypes[0] = String.class;
Method getService= ServiceManager.getMethod("getService", partypes );
Object arglist[] = new Object[1];
arglist[0] = "SurfaceFlinger";
IBinder flinger= (IBinder)getService.invoke(smObject, arglist );
// IBinder flinger = ServiceManager.getService("SurfaceFlinger");
if (flinger != null) {
Parcel data = Parcel.obtain();
data.writeInterfaceToken("android.ui.ISurfaceComposer");
data.writeInt(isChecked ? 1 : 0);
flinger.transact(mCode, data, null, 0);
data.recycle();
updateFlingerOptions();
}
} catch (RemoteException ex) {
}
**catch (SecurityException e) {
// TODO Auto-generated catch block
String err=e.toString();
Toast.makeText(DevelopmentSetting.this, err, Toast.LENGTH_SHORT).show();
}**
catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}在catch SecurityException中,它给出了错误java.lang.securityException,但在logcat中,它显示权限被拒绝: can't access surfaceFlinger。
manifest.xml就在这里
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nustian.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"/>
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".DevelopmentSetting"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>谁来帮帮我。
发布于 2013-09-20 21:59:13
您的应用程序需要使用平台证书签名才能访问此权限。只有系统应用程序通常才有这个功能。更多信息请点击此处:
https://groups.google.com/forum/#!topic/android-porting/aN6D_vL9xxE
发布于 2014-07-13 13:29:00
作为一种解决方法,请将此代码添加到清单文件中。UID media能够使用surface flinger app,因此与其共享UID将允许您的应用程序也使用它。
coreApp="true"
android:sharedUserId="android.uid.media"发布于 2012-04-16 14:51:38
别忘了添加它的相对权限:
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" /> https://stackoverflow.com/questions/10169591
复制相似问题