运行我的应用程序时出现此错误。我也包含在manifest.xml中权限拒绝:无法访问SurfaceFlinger
"uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"
为SurfaceFlinger的权限但仍给了同样的错误" can't access the SurfaceFlinger"
在logcat中。
基本上我想在开发工具中运行开发设置代码。
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();
}
}
}
在捕获SecurityException它给出了错误java.lang.securityException,但logcat它说权限被拒绝:无法访问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>
有人帮我。
请发表完整的例外。 – MahdeTo 2012-04-16 06:29:18