本文整理匯總了Java中android.app.Activity.getLocalClassName方法的典型用法代碼示例。如果您正苦於以下問題:Java Activity.getLocalClassName方法的具體用法?Java Activity.getLocalClassName怎麽用?Java Activity.getLocalClassName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.Activity
的用法示例。
在下文中一共展示了Activity.getLocalClassName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showInstructions
import android.app.Activity; //導入方法依賴的package包/類
/**
* Shows the instructions overlay over the activity specified if they have not been showed before
* @param activity activity onto which to overlay instructions
*/
public static void showInstructions(Activity activity) {
//this is a global variable that is stored with the app memory in the phone forever in order to know
//whether instructions have been shown before or not, as we do not want to show instructions
//all the time the app is started
String preferenceKeyword = "RanBefore_" + activity.getLocalClassName();
System.out.println(preferenceKeyword);
SharedPreferences preferences = activity.getPreferences(MODE_PRIVATE);
boolean ranBefore = preferences.getBoolean(preferenceKeyword, false);
//TODO: remove this
// String mode;
// if(activity.getClass().equals(MainActivity.class)) {
// mode = INSTRUCTION_MAIN;
// } else {
// mode = INSTRUCTION_NEW;
// }
System.out.println(mainAlready);
System.out.println(newAlready);
//TODO: change de if with the commented if below when ready to deploy app
if (!ranBefore) {
//if((mode.equals(INSTRUCTION_MAIN) && !mainAlready) || (mode.equals(INSTRUCTION_NEW) && !newAlready) ) {
//sets the value of the long term variable to true (meaning that instructions have been
//shown already for the specific activity).
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(preferenceKeyword, true);
editor.commit();
Intent intent = new Intent(activity.getApplicationContext(), InstructionsActivity.class);
if (activity.getClass().equals(MainActivity.class)) {
intent.putExtra(INSTRUCTION, INSTRUCTION_MAIN);
mainAlready = true;
} else {
intent.putExtra(INSTRUCTION, INSTRUCTION_NEW);
newAlready = true;
}
//start instructions activity
activity.startActivity(intent);
}
}