当前位置: 首页>>代码示例>>Java>>正文


Java Activity.getLocalClassName方法代码示例

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

        }
    }
 
开发者ID:mcr222,项目名称:pass_the_bomb,代码行数:46,代码来源:InstructionsActivity.java


注:本文中的android.app.Activity.getLocalClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。