私は、以下を含む共有設定を持つAndroidアプリケーションを開発しています: - 着信音 (完了)
- ダイアログ通知(アラーム、SMS、MMS)を無効にします(まだコード内のコメントを読んでください)
-友達に教えてください(私のコードは正しいと確信していますが、共有設定でそれを配置する方法がわかりません+配置する場所と方法がわかりました-コード内のコメントを読んでください)
public class Setting extends PreferenceActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
String ringtonePreference;
// Get the xml/preferences.xml preferences
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
ringtonePreference = prefs.getString("ringtonePref",
"DEFAULT_RINGTONE_URI");
}
//disable all Notification (Alarm , SMS,MMS)
//what is the method that i should put this code at it? onStart?onDestroy?or what?
SharedPreferences sharedPreferences = this.getPreferences(MODE_PRIVATE);
boolean hideNotification = sharedPreferences.getBoolean("checkbox", false);
if(!hideNotification)
alertDialog.show();
}
//tell friend
//i am not sure if this is right place to this code
//if it is the right place then what is the method that i should put this code at it?onStart?onActivityResult?or what?
SharedPreferences prefs1 = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
TellFriendPreference = prefs1.getString("tellfriend","null");
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String item = (String) getListAdapter().getItem(position);
String str= item.toString();
if(str=="Tell Friends"){
Toast.makeText(this,"First", Toast.LENGTH_LONG).show();
//Go to tell friend activity
//Intent i = new Intent (Help.this, .class);
//startActivity(i);
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(android.content.Intent.EXTRA_TEXT, "Check out s Application for Android. Download it today from http://s.com");
startActivity(Intent.createChooser(intent, "Tell friends:"));
startActivity(intent);
}
これは prefs.xml です
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="Second Category" >
<RingtonePreference
android:name="Ringtone Preference"
android:key="ringtonePref"
android:summary="Select a ringtone"
android:title="Ringtones" />
<CheckBoxPreference
android:defaultValue="true"
android:key="checkbox"
android:summary="Check the Box"
android:title="Disable Notification" />
<Preference
android:name="tell Preference"
android:key="tellfriend"
android:summary="if u want to tell ur friends by usinf"
android:title="Tell Friend" />
</PreferenceCategory>
</PreferenceScreen>
助けてください。数時間後に送信する必要があります