我有一个Android应用程序,用户点击一个按钮,并触发这样的事件:
img.top(); //Images img; it's another class
currentTop = img.getcTop(); // a method in the other class
TopBorder.setImageBitmap(currentTop); //top border is an imageview
其中img是另一个类的Images img;
个全局变量,而位图currentTop
从另一个类获取当前的img
public void top(){
topColor++; //global int for switching images
//using switch for adding more in future
if(topColor>2){
topColor = 1;
}
switch(topColor){
case 1:
cTop = topblue;
break;
case 2:
cTop = topred;
break;
}
}
cTop
代表其他图片,我使用decodestream
来定义其他图片
InputStream istb = getResources().openRawResource(R.drawable.borderbluet);
topblue = BitmapFactory.decodeStream(istb);
logcat说
01-08 15:10:18.851: E/DatabaseUtils(2953): Writing exception to parcel
01-08 15:10:18.851: E/DatabaseUtils(2953): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
01-08 15:10:18.851: E/DatabaseUtils(2953): at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13082)
01-08 15:10:18.851: E/DatabaseUtils(2953): at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
01-08 15:10:18.851: E/DatabaseUtils(2953): at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:577)
01-08 15:10:18.851: E/DatabaseUtils(2953): at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
01-08 15:10:18.851: E/DatabaseUtils(2953): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
01-08 15:10:18.851: E/DatabaseUtils(2953): at android.os.Binder.execTransact(Binder.java:388)
01-08 15:10:18.851: E/DatabaseUtils(2953): at dalvik.system.NativeStart.run(Native Method)
位图不是静态的,也不是吸气剂。当我在一堂课中宣布这些应用程序时,该应用程序运行正常。但是我不想让这个类有太多方法可以在将来轻松修改。
任何帮助将不胜感激谢谢。