ステータスバーにスマイリーの「通知」アイコンの画像を表示するアプリがあります。(それがアプリの目的です。そのスマイリーを表示するだけです)そして、設定で表示されるアイコンを変更できるようにしたいと考えています。最初にアイコンがどのように表示されるかについての私のコードは次のとおりです。ご覧のとおり、drawable フォルダーからロードします。
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Smiley Notification Starts
NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification=new Notification(R.drawable.smiley_notification, "Smiley", System.currentTimeMillis());
Context context=MainActivity.this;
CharSequence title="Smiley Title";
CharSequence detail="Touch for more options";
Intent intent=new Intent(context,MainActivity.class);
PendingIntent pending=PendingIntent.getActivity(context, 0, intent, 0);
notification.setLatestEventInfo(context, title, detail, pending);
nm.notify(0, notification);
//Smiley Notification Ends
そして、これが私の設定xmlファイルです。
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Additional Information" android:summary="More">
<PreferenceScreen android:title="My Name" android:summary="Smiley Notification Developer">
<intent android:action="android.intent.action.VIEW" android:data="http://instagram.com/AccountName" />
</PreferenceScreen>
<Preference
android:title="Requests/Support"
android:summary="Click here to email me">
<intent
android:action="android.intent.action.VIEW"
android:data="mailto:email@email.com?subject=Support*Smiley Lite">
<extra android:name="android.intent.extra.TEXT" android:value="Enter your request or problem here with a brief description." />
</intent>
</Preference>
<PreferenceScreen android:title="More apps by provider" android:summary="Click here">
<intent android:action="android.intent.action.VIEW" android:data="http://website.com" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
別のアイコン(画像)をロードするためにチェックボックスのように追加する方法を教えていただければ、それは素晴らしいことです。どうもありがとうございました。