重複の可能性:
特定のアクティビティに対してアプリを再起動しますか?
現在、ユーザーアカウントを削除するためのDialogPreferencesアクティビティを作成しています。ユーザーデータを完全に削除しました。ユーザーに新規インストールをプッシュするために、LAUNCHER画面に戻ることを計画しています。しかし、私は本当に戻る方法を見つけることができませんでした。
インテントは、私が理解している限り、XMLファイルからのみ使用できます。
StartActivity()を使用したり、DialogPreferencesアクティビティでアプリケーションを再起動したりする方法はありますか?
public class DeleteAccountActivity extends DialogPreference {
public DeleteAccountActivity(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
if (DEBUG)
Log.d(0, DEBUG_TAG, "DeleteAccountActivity");
try {
...
boolean success = rest.deregister(request);
if (success) {
Toast.makeText(getContext(),
getContext().getResources().getText(R.string.successfully_deleted_account),
Toast.LENGTH_LONG).show();
SharedPreferences.Editor editor = mSharedPref.edit();
editor.clear();
editor.commit();
Intent intent = new Intent();
intent.setClass(this, A.class);
StartActivity(intent); //error
if (DEBUG)
Log.d(0, DEBUG_TAG, "Deleted the user account successfully.");
}
}
catch (Exception e) {
Log.e(0, DEBUG_TAG, "asd", e);
}
}
}
}