本文整理汇总了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);
}
}