List of usage examples for android.app Activity getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.solovyev.android.calculator.ActivityUi.java
@Nonnull private String getSavedTabPreferenceName(@Nonnull Activity activity) { return "tab_" + activity.getClass().getSimpleName(); }
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.dialogs.AboutDialogFragment.java
@Override public void onAttach(final Activity activity) { super.onAttach(activity); try {/*from w w w. j ava 2 s. c om*/ callbacks = (Callbacks) activity; } catch (ClassCastException e) { throw new IllegalStateException( activity.getClass().getName() + " does not implement " + Callbacks.class.getName()); } }
From source file:com.lkunic.lib.activityaddonlib.twopane.fragments.ItemListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // Activities containing this fragment must implement its callback if (!(activity instanceof Callbacks)) { throw new IllegalStateException( String.format("%s must implement fragment's callbacks.", activity.getClass().getName())); }/*w ww. j av a 2 s . c om*/ mCallbacks = (Callbacks) activity; }
From source file:com.lkunic.libs.apptoolbox.twopane.fragments.ItemListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // Activities containing this fragment must implement its callback if (!(activity instanceof OnItemSelectedListener)) { throw new IllegalStateException( String.format("%s must implement fragment's callbacks.", activity.getClass().getName())); }/*from w ww . j a v a 2s . co m*/ mListener = (OnItemSelectedListener) activity; }
From source file:com.yahoo.mobile.client.android.yodel.ui.PostDetailFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (!(activity instanceof Callback)) { throw new IllegalStateException("Activity " + activity.getClass().getSimpleName() + " must implement PostDetailFragment.Callbacks"); } else {// w w w. j av a 2s. c o m mCallbackHandler = (Callback) activity; } }
From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java
private static int loadUiOptionsFromManifest(Activity activity) { int uiOptions = 0; try {//from w w w. j a va 2 s . c o m final String thisPackage = activity.getClass().getName(); if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); final String packageName = activity.getApplicationInfo().packageName; final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); int eventType = xml.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { String name = xml.getName(); if ("application".equals(name)) { //Check if the <application> has the attribute if (DEBUG) Log.d(TAG, "Got <application>"); for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); if ("uiOptions".equals(xml.getAttributeName(i))) { uiOptions = xml.getAttributeIntValue(i, 0); break; //out of for loop } } } else if ("activity".equals(name)) { //Check if the <activity> is us and has the attribute if (DEBUG) Log.d(TAG, "Got <activity>"); Integer activityUiOptions = null; String activityPackage = null; boolean isOurActivity = false; for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); //We need both uiOptions and name attributes String attrName = xml.getAttributeName(i); if ("uiOptions".equals(attrName)) { activityUiOptions = xml.getAttributeIntValue(i, 0); } else if ("name".equals(attrName)) { activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i)); if (!thisPackage.equals(activityPackage)) { break; //out of for loop } isOurActivity = true; } //Make sure we have both attributes before processing if ((activityUiOptions != null) && (activityPackage != null)) { //Our activity, uiOptions specified, override with our value uiOptions = activityUiOptions.intValue(); } } if (isOurActivity) { //If we matched our activity but it had no logo don't //do any more processing of the manifest break; } } } eventType = xml.nextToken(); } } catch (Exception e) { e.printStackTrace(); } if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions)); return uiOptions; }
From source file:com.lee.sdk.utils.Utils.java
/** * ????//from w ww . j a v a2 s.c om * * @param activity ?Activity??? * @param nameId ???? * @param iconId ?? * @param appendFlags ????IntentFlag */ public static void addShortcut(Activity activity, int nameId, int iconId, int appendFlags) { Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); // ???? shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, activity.getString(nameId)); shortcut.putExtra("duplicate", false); // ???? // ?Activity??? ComponentName comp = new ComponentName(activity.getPackageName(), activity.getClass().getName()); Intent intent = new Intent(Intent.ACTION_MAIN).setComponent(comp); if (appendFlags != 0) { intent.addFlags(appendFlags); } shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); // ?? ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(activity, iconId); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); activity.sendBroadcast(shortcut); }
From source file:com.teddoll.movies.MovieListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {// www. ja v a 2s . c o m this.listener = (MovieListFragmentListener) activity; } catch (ClassCastException e) { throw new IllegalArgumentException( activity.getClass().getSimpleName() + " Must implement MovieListFragmentListener"); } }
From source file:de.dknapps.pswgendroid.ServiceListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // Activity-Klassen, die dieses Fragment nutzen, mssen {@link Listener} implementieren if (!(activity instanceof Listener)) { throw new ClassCastException( activity.getClass().getName() + " must implement " + Listener.class.getName()); }//from w w w . j a va 2 s. c om listener = (Listener) activity; }
From source file:com.pomelodesign.cordova.metaio.MetaioPlugin.java
public String GetConfigFilePath(Activity action) { if (action == null) { return null; }/*from w ww .ja v a 2 s . c om*/ int id = action.getResources().getIdentifier("config", "xml", action.getClass().getPackage().getName()); if (id == 0) { id = action.getResources().getIdentifier("cordova", "xml", action.getPackageName()); return null; } if (id == 0) { return null; } XmlResourceParser xml = action.getResources().getXml(id); int eventType = -1; while (eventType != XmlResourceParser.END_DOCUMENT) { if (eventType == XmlResourceParser.START_TAG) { String strNode = xml.getName(); if (strNode.equals("preference")) { String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.getDefault()); if (name.equalsIgnoreCase("arelConfigPath")) { String arelConfigPath = xml.getAttributeValue(null, "value"); return arelConfigPath; } } } try { eventType = xml.next(); } catch (XmlPullParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return null; }