當前位置: 首頁>>代碼示例>>Java>>正文


Java Activity.getClass方法代碼示例

本文整理匯總了Java中android.app.Activity.getClass方法的典型用法代碼示例。如果您正苦於以下問題:Java Activity.getClass方法的具體用法?Java Activity.getClass怎麽用?Java Activity.getClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.getClass方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isSupportActivity

import android.app.Activity; //導入方法依賴的package包/類
private static boolean isSupportActivity(Activity activity) {
    boolean isSupport = false;
    for (Class<?> c = activity.getClass().getSuperclass();; c = c.getSuperclass()) {
        if (c == null) {
            throw new RuntimeException("Illegal activity type: " + activity.getClass());
        }
        String name = c.getName();
        if (name.equals("android.support.v4.app.FragmentActivity")) {
            isSupport = true;
            break;
        } else if (name.startsWith("com.actionbarsherlock.app")
                && (name.endsWith(".SherlockActivity") || name.endsWith(".SherlockListActivity") || name
                        .endsWith(".SherlockPreferenceActivity"))) {
            throw new RuntimeException("Please use SherlockFragmentActivity. Illegal activity: " + name);
        } else if (name.equals("android.app.Activity")) {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
                throw new RuntimeException(
                        "Illegal activity without fragment support. Either use Android 3.0+ or android.support.v4.app.FragmentActivity.");
            }
            break;
        }
    }
    return isSupport;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:ErrorDialogManager.java

示例2: injectView

import android.app.Activity; //導入方法依賴的package包/類
private static void injectView(Activity activity) {
    Class<? extends Activity> clazz = activity.getClass();
    // 獲取所有的成員變量
    Field[] fields = clazz.getDeclaredFields();
    for (Field field : fields) {
        ViewInject inject = field.getAnnotation(ViewInject.class);
        if (inject != null) {
            int viewId = inject.value();
            View view = activity.findViewById(viewId);
            field.setAccessible(true);
            try {
                field.set(activity, view);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:19,代碼來源:ViewInjectUtils.java

示例3: ActionBarHelper

import android.app.Activity; //導入方法依賴的package包/類
public ActionBarHelper(Activity activity) {
    mActivity = activity;

    try {
        Class clazz = activity.getClass();
        Method m = clazz.getMethod("getSupportActionBar");
        mUsesCompat = true;
    } catch (NoSuchMethodException e) {
        if (DEBUG) {
            Log.e(TAG,
                    "Activity " + activity.getClass().getSimpleName() + " does not use a compatibility action bar",
                    e);
        }
    }

    mIndicatorInfo = getIndicatorInfo();
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:18,代碼來源:ActionBarHelper.java

示例4: isSupportActivity

import android.app.Activity; //導入方法依賴的package包/類
private static boolean isSupportActivity(Activity activity) {
    Class<?> c = activity.getClass().getSuperclass();
    while (c != null) {
        String name = c.getName();
        if (name.equals("android.support.v4.app.FragmentActivity")) {
            return true;
        }
        if (name.startsWith("com.actionbarsherlock.app") && (name.endsWith(".SherlockActivity") || name.endsWith(".SherlockListActivity") || name.endsWith(".SherlockPreferenceActivity"))) {
            throw new RuntimeException("Please use SherlockFragmentActivity. Illegal activity: " + name);
        } else if (!name.equals("android.app.Activity")) {
            c = c.getSuperclass();
        } else if (VERSION.SDK_INT >= 11) {
            return false;
        } else {
            throw new RuntimeException("Illegal activity without fragment support. Either use Android 3.0+ or android.support.v4.app.FragmentActivity.");
        }
    }
    throw new RuntimeException("Illegal activity type: " + activity.getClass());
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:ErrorDialogManager.java

示例5: buildMembersList

import android.app.Activity; //導入方法依賴的package包/類
private Content buildMembersList() {
    try {
        Activity activity = CommonUtils.getCurrentActivity();
        if (activity == null) {
            return new ErrorPage("Activity not available for listing").getContent();
        } else {
            Class clazz = activity.getClass();
            Content content = new Content();
            content.add(new HeadingContentPart(4, "Fields"));
            content.add(getFieldsList(activity, clazz));
            content.add(new HeadingContentPart(4, "Methods"));
            content.add(getMethodsList(clazz));
            return content;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return new ErrorPage(e.getMessage()).getContent();
    }
}
 
開發者ID:bartwell,項目名稱:ultra-debugger,代碼行數:20,代碼來源:Module.java

示例6: onAttach

import android.app.Activity; //導入方法依賴的package包/類
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    context = activity.getApplicationContext();

    try {
        fragmentListener = (MessageListFragmentListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.getClass() +
                " must implement MessageListFragmentListener");
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:14,代碼來源:MessageListFragment.java

示例7: getAppThemeExpanded

import android.app.Activity; //導入方法依賴的package包/類
/**
 * Manipulate the application theme with TRASLUCENT actionbar:
 * Based on the corresponding theme (1-7) this method will:
 * set the theme
 * colorize the actionbar accordinlgy
 * adjust the padding of the icon
 * colorize (if >lollipop) the multitask
 * colorize (if>KK) the statusbar
 * <p/>
 * this returns a drawable that corresponds to the actionbar background
 * later to be manipulated by the corresponding activity
 *
 * @param context
 */
public static Drawable getAppThemeExpanded(final Activity context,
                                           Drawable mActionBarBackgroundDrawable) {

    int Theme = Integer.valueOf(PreferenceManager
            .getDefaultSharedPreferences(context).getString(
                    PreferencesActivity.KEY_THEME, "3"));

    mActionBarBackgroundDrawable = getThemeDrawable(context, Theme);

    if (Theme == 4) {
        context.setTheme(R.style.BlackTheme55);
    } else if (Theme == 1 || Theme == 7) {
        context.setTheme(R.style.CustomTheme55);
        context.getActionBar().setSplitBackgroundDrawable(
                mActionBarBackgroundDrawable);
        context.getActionBar().setStackedBackgroundDrawable(
                mActionBarBackgroundDrawable);
    } else {
        context.setTheme(R.style.ThunderMusic55);
        context.getActionBar().setSplitBackgroundDrawable(
                mActionBarBackgroundDrawable);
        context.getActionBar().setStackedBackgroundDrawable(
                mActionBarBackgroundDrawable);

    }

    ImageView view = (ImageView) context.findViewById(android.R.id.home);
    int paddingRight;

    if (context.getClass() == MediaPlaybackActivity.class) {
        paddingRight = (int) TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 16, context.getResources()
                        .getDisplayMetrics());
    } else {

        paddingRight = (int) TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 24, context.getResources()
                        .getDisplayMetrics());
    }

    int paddingLeft = (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, 21, context.getResources()
                    .getDisplayMetrics());
    view.setPadding(paddingLeft, 0, paddingRight, 0);

    mActionBarBackgroundDrawable.setAlpha(0);
    context.getActionBar().setIcon(R.drawable.ic_action_back);
    context.getActionBar().setBackgroundDrawable(
            mActionBarBackgroundDrawable);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        if (Theme < 6)
            context.setTaskDescription(new ActivityManager.TaskDescription(
                    context.getString(R.string.musicbrowserlabel),
                    BitmapFactory.decodeResource(context.getResources(),
                            R.drawable.app_music), context.getResources()
                    .getColor(getThemeColor(context, Theme))));
        else
            context.setTaskDescription(new ActivityManager.TaskDescription(
                    context.getString(R.string.musicbrowserlabel),
                    BitmapFactory.decodeResource(context.getResources(),
                            R.drawable.app_music), getThemeColor(context,
                    Theme)));
    }
    return mActionBarBackgroundDrawable;
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:82,代碼來源:ThemeUtils.java

示例8: getSpecialActivity

import android.app.Activity; //導入方法依賴的package包/類
/**
 * 調用此方法前請務必確認activity在堆棧中,否則將死循環
 * @param cls
 * @return
 */
public Activity getSpecialActivity(Class<?> cls) {
	for (Activity activity:mActivityStack) {
		if (cls == activity.getClass()) {
			return activity;
		}
	}
	return null;
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:14,代碼來源:ActivitiesManager.java

示例9: setupForegroundDispatch

import android.app.Activity; //導入方法依賴的package包/類
private static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter)
{
    final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass());

    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0);

    IntentFilter[] filters = new IntentFilter[1];
    String[][] techList = new String[][]{};

    filters[0] = new IntentFilter();
    filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED);
    filters[0].addCategory(Intent.CATEGORY_DEFAULT);

    try
    {
        /* Mime type for BT pairing */
        filters[0].addDataType("application/vnd.bluetooth.ep.oob");
    }
    catch (IntentFilter.MalformedMimeTypeException e)
    {
        throw new RuntimeException("Unsupported mime type!");
    }

    /* Start Foreground dispatcher */
    adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList);
}
 
開發者ID:AinaWireless,項目名稱:PairingExample,代碼行數:29,代碼來源:MainActivity.java

示例10: createPendingIntent

import android.app.Activity; //導入方法依賴的package包/類
private void createPendingIntent() {
    if (pendingIntent == null) {
        Activity activity = getActivity();
        Intent intent = new Intent(activity, activity.getClass());
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0);
    }
}
 
開發者ID:RoopeHakulinen,項目名稱:cordova-plugin-mifare-ultralight,代碼行數:9,代碼來源:CordovaPluginMifareUltralight.java

示例11: restoreApp

import android.app.Activity; //導入方法依賴的package包/類
private static void restoreApp(Activity activity) {
    Intent i = new Intent(activity, activity.getClass());
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    i.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    i.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    activity.startActivity(i);
}
 
開發者ID:myl2ning,項目名稱:fragmentnav,代碼行數:10,代碼來源:FmTest.java

示例12: setActivity

import android.app.Activity; //導入方法依賴的package包/類
public static void setActivity(Activity activity, Class<? extends Activity> claz) {
    context = activity.getApplicationContext();
    activityClass = claz == null ? activity.getClass() : claz;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:CountlyMessaging.java

示例13: attachTo

import android.app.Activity; //導入方法依賴的package包/類
/** Scope is limited to the activity's class. */
public static void attachTo(Activity activity, boolean finishAfterDialog, Bundle argumentsForErrorDialog) {
    Object executionScope = activity.getClass();
    attachTo(activity, executionScope, finishAfterDialog, argumentsForErrorDialog);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:ErrorDialogManager.java


注:本文中的android.app.Activity.getClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。