Example usage for android.app Activity getClass

List of usage examples for android.app Activity getClass

Introduction

In this page you can find the example usage for android.app Activity getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:cn.bingoogolapple.scaffolding.util.UMAnalyticsUtil.java

/**
 *  ActivityLifecycleCallbacks  onActivityPaused 
 *
 * @param activity/*from   w w w  .j  a v  a2 s  . c o m*/
 */
public static void onActivityPaused(Activity activity) {
    if (sIsInit) {
        // ?
        if (AppManager.getInstance().isActivityNotContainFragment(activity)) {
            // ?? onPageEnd  onPause ?, onPause ??
            MobclickAgent.onPageEnd(activity.getClass().getSimpleName());
        }
        // 
        MobclickAgent.onPause(activity);
    }
}

From source file:gr.scify.newsum.Utils.java

/**
 * Set the theme of the Activity, and restart it by creating a new Activity
 * of the same type./*from  ww  w. j av a2s .  c  o  m*/
 */
public static void changeToTheme(Activity activity, int theme) {
    sTheme = theme;
    activity.finish();

    activity.startActivity(new Intent(activity, activity.getClass()));
}

From source file:Main.java

public static boolean startLastActivity(Activity activity) {
    try {// ww w.j a  va 2 s.  c  om
        BufferedReader reader = new BufferedReader(new InputStreamReader(activity.openFileInput(FILENAME)));
        String nextClassName = reader.readLine();
        reader.close();

        if (null == nextClassName || nextClassName.length() < 3) {
            return false;
        }

        String currClassName = activity.getClass().getName();
        if (currClassName.equals(nextClassName)) {
            return false;
        }

        @SuppressWarnings("unchecked")
        Class<? extends Activity> clazz = (Class<? extends Activity>) Class.forName(nextClassName);
        if (null == clazz) {
            return false;
        }

        Intent i = new Intent(activity, clazz);
        activity.startActivity(i);
        activity.finish();
        reader.close();

        return true;
    } catch (Exception e) {
        Toast.makeText(activity, "startLastActivity: " + e, Toast.LENGTH_LONG).show();
    }
    return false;
}

From source file:com.arantius.tivocommander.Utils.java

@SuppressLint("NewApi")
final static void addToMenu(Menu menu, Activity activity, int itemId, int iconId, String title,
        int showAsAction) {
    if (Utils.activityForMenuId(itemId) == activity.getClass()) {
        return;/*  w ww  .  j av  a  2  s.  c o m*/
    }
    MenuItem menuitem = menu.add(Menu.NONE, itemId, Menu.NONE, title);
    menuitem.setIcon(iconId);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuitem.setShowAsAction(showAsAction);
    }
}

From source file:Main.java

public static boolean startActivityUsingScheme(Activity a, String scheme, Bundle args) {
    Uri uri = Uri.parse(scheme + "://");
    Intent intent = new Intent(Intent.ACTION_RUN, uri);
    boolean result = true;
    try {//from   w w  w. j  av a2 s .c  o  m
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (args != null)
            intent.putExtras(args);
        a.startActivity(intent);
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = false;
    }
    return result;
}

From source file:io.digibyte.tools.animation.BRAnimator.java

public static void startBreadActivity(Activity from, boolean auth) {
    if (from == null)
        return;// ww w  .ja  v a2 s.c  o  m
    Log.e(TAG, "startBreadActivity: " + from.getClass().getName());
    Class toStart = auth ? LoginActivity.class : BreadActivity.class;
    Intent intent = new Intent(from, toStart);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    from.startActivity(intent);
    from.overridePendingTransition(R.anim.fade_up, R.anim.fade_down);
    if (!from.isDestroyed()) {
        from.finish();
    }
}

From source file:foundme.uniroma2.it.professore.HomeActivity.java

public 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);//from  w  w w .j  a  v a 2  s  . c  o  m

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

    //Stesso filtro del Manifest.
    filters[0] = new IntentFilter();
    filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED);
    filters[0].addCategory(Intent.CATEGORY_DEFAULT);
    try {
        filters[0].addDataType(Variables_it.MIME_TEXT_PLAIN);
    } catch (IntentFilter.MalformedMimeTypeException e) {
        throw new RuntimeException(Variables_it.MIME_ERROR);
    }

    adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList);
}

From source file:org.onebusaway.android.directions.realtime.RealtimeService.java

/**
 * Start realtime updates./*  w  w  w . ja  va  2 s .  c om*/
 *
 * @param source Activity from which updates are started
 * @param bundle Bundle with selected itinerary/parameters
 */
public static void start(Activity source, Bundle bundle) {

    SharedPreferences prefs = Application.getPrefs();
    if (!prefs.getBoolean(OTPConstants.PREFERENCE_KEY_LIVE_UPDATES, true)) {
        return;
    }

    bundle.putSerializable(OTPConstants.NOTIFICATION_TARGET, source.getClass());
    Intent intent = new Intent(OTPConstants.INTENT_START_CHECKS);
    intent.putExtras(bundle);
    source.sendBroadcast(intent);
}

From source file:Main.java

public static boolean startActivity(Activity a, String packageName, Bundle args, int flags) {
    PackageManager pm = a.getPackageManager();
    boolean result = true;
    try {//from  ww  w. j ava  2 s .  c om
        Intent intent = pm.getLaunchIntentForPackage(packageName);
        if (null != intent) {
            intent.addFlags(flags);
            if (args != null)
                intent.putExtras(args);
            a.startActivity(intent);
        }
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = false;
    }
    return result;
}

From source file:de.uni_koblenz_landau.apow.PatientListActivity.java

/**
 * Start scanning for NFC tags./*from  w  w w  .  j  ava 2s . com*/
  * @param activity The Activity requesting to the foreground dispatch.
  * @param adapter The NfcAdapter used for the foreground dispatch.
 */
private static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) {
    if (adapter != null) {
        // Add intents for NFC.
        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_TAG_DISCOVERED);
        filters[0].addCategory(Intent.CATEGORY_DEFAULT);

        adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList);
    }
}