当前位置: 首页>>代码示例>>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;未经允许,请勿转载。