當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。