我整天都在努力解决这个问题而且没有成功.我基本上试图从另一个apk获取图像资源.
因此,如果com.example.app在res文件夹中有一个名为image1.png的图像,我希望com.example2.app能够访问该资源并将其放在imageview中.
我知道你必须使用PackageManager.getResourcesForApplication,但我仍然没有成功获得实际资源.
任何帮助都是极好的!
我正在尝试从服务访问共享首选项.我已经使用以下内容将文本的值保存到字符串中...
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("Ignore1_value", Example.getText().toString());
editor.commit();
Run Code Online (Sandbox Code Playgroud)
但是,我如何获得服务的价值?我尝试过的一切都没有回报.任何帮助都是完美的,非常感谢?
我也查看了其他一些问题而没有解决方案.我想出了这个,但就像我说的那样,它没有文字.
Context ctx = getApplicationContext();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
String example1string = sharedPreferences.getString("Ignore1_value","");
Log.i("**GetSettings", example1string);
Run Code Online (Sandbox Code Playgroud)