PackageManager getActivityInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PackageManager getActivityInfo method.

This code example shows how to use the following methods:getActivityInfo
        xml.close();
    } 
 
    @SmallTest 
    public void testActivityWithData() throws Exception { 
        ComponentName cn = new ComponentName(mContext, LocalActivity.class);
        ActivityInfo ai = mContext.getPackageManager().getActivityInfo(
                cn, PackageManager.GET_META_DATA);
 
        checkMetaData(cn, ai);
 
        ai = mContext.getPackageManager().getActivityInfo(cn, 0);
 
        assertNull("Meta data returned when not requested", ai.metaData);
    } 
 
    @SmallTest 
    public void testReceiverWithData() throws Exception { 
        ComponentName cn = new ComponentName(mContext, LocalReceiver.class);
        ActivityInfo ai = mContext.getPackageManager().getReceiverInfo(
6
CodeRank
This code example shows how to use the following methods:getActivityInfo, getPackageInfo
        ComponentName componentName = searchable.getSearchActivity();
        if (DBG) Log.d(TAG, "created Searchable for " + componentName);
        mSearchable = searchable;
        mName = componentName.flattenToShortString();
        PackageManager pm = context.getPackageManager();
        mActivityInfo = pm.getActivityInfo(componentName, 0);
        PackageInfo pkgInfo = pm.getPackageInfo(componentName.getPackageName(), 0);
        mVersionCode = pkgInfo.versionCode;
    } 
 
    public SearchableInfo getSearchableInfo() {
        return mSearchable;
    } 
 
    /** 
     * Checks if the current process can read the suggestion provider in this source. 
     */ 
    public boolean canRead() { 
        String authority = mSearchable.getSuggestAuthority();
        if (authority == null) {
6
CodeRank
This code example shows how to use the following methods:getActivityInfo
    } 
 
    private CharSequence loadLabel(Context context, ComponentName activityName) {
        PackageManager pm = context.getPackageManager();
        try { 
            ActivityInfo ai = pm.getActivityInfo(activityName, 0);
            return ai.loadLabel(pm);
        } catch (PackageManager.NameNotFoundException ex) {
            Log.e(TAG, "Web search activity not found: " + activityName);
            return null; 
        } 
    } 
 
    public String getName() {
        String packageName = mSearchable.getSearchActivity().getPackageName();
        // Use "google" as name to avoid showing Google twice (app + OpenSearch) 
        if ("com.google.android.googlequicksearchbox".equals(packageName)) {
            return SearchEngine.GOOGLE; 
        } else if ("com.android.quicksearchbox".equals(packageName)) {
            return SearchEngine.GOOGLE; 
6
CodeRank
This code example shows how to use the following methods:getActivityInfo
 
    private boolean detectIfPurgeableRequest() { 
        PackageManager pm = getPackageManager();
        CharSequence labelSeq = null;
        try { 
          ActivityInfo info = pm.getActivityInfo(this.getComponentName(),
              PackageManager.GET_META_DATA);
          labelSeq = info.loadLabel(pm);
        } catch (NameNotFoundException e) {
          e.printStackTrace();
          return false; 
        } 
 
        String[] components = labelSeq.toString().split("/");
        if (components[components.length - 1].equals("Purgeable")) {
            return true; 
        } else { 
            return false; 
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:getActivityInfo
        xml.close();
    } 
 
    @SmallTest 
    public void testActivityWithData() throws Exception { 
        ComponentName cn = new ComponentName(mContext, LocalActivity.class);
        ActivityInfo ai = mContext.getPackageManager().getActivityInfo(
                cn, PackageManager.GET_META_DATA);
 
        checkMetaData(cn, ai);
 
        ai = mContext.getPackageManager().getActivityInfo(cn, 0);
 
        assertNull("Meta data returned when not requested", ai.metaData);
    } 
 
    @SmallTest 
    public void testReceiverWithData() throws Exception { 
        ComponentName cn = new ComponentName(mContext, LocalReceiver.class);
        ActivityInfo ai = mContext.getPackageManager().getReceiverInfo(
6
CodeRank
This code example shows how to use the following methods:getActivityInfo
				.getResources().getConfiguration().orientation);
 
		/// Method 2: Retrieve info about Activity as collected from AndroidManifest.xml 
		// https://developer.android.com/reference/android/content/pm/ActivityInfo.html 
		PackageManager packageManager = currentActivity.getPackageManager();
		ActivityInfo activityInfo = packageManager.getActivityInfo(currentActivity.getComponentName(),
				PackageManager.GET_ACTIVITIES);
 
		// Note that the activity is _indeed_ rotated on your device/emulator! 
		// Robotium can _force_ the activity to be in landscape mode (and so could we, programmatically) 
		solo.setActivityOrientation(Solo.LANDSCAPE); 
		solo.sleep(200); 
 
		assertEquals(ScriptActivity.class.getSimpleName() + " not set to be in portrait mode in AndroidManifest.xml!",
				ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, activityInfo.screenOrientation);
	} 
 
	public void testMainMenuButton() { 
		UiTestUtils.waitForFragment(solo, R.id.fragment_script); 
 
5
CodeRank
This code example shows how to use the following methods:getActivityInfo
	 
	@Override 
	public ActivityInfo getActivityInfo(Context context, Class<?> cls) {
		try { 
			final PackageManager packageManager = context.getPackageManager();
			return packageManager.getActivityInfo(new ComponentName(context, cls), 0);
		} 
		catch (NameNotFoundException e) {
			if(logger != null) {
				logger.error("Failed to locate info for activity [" +
						cls.getName() +
						"]", e);
			} 
			else { 
				SocializeLogger.e(e.getMessage(), e);
			} 
		} 
		 
		return null; 
	} 
5
CodeRank
This code example shows how to use the following methods:getActivityInfo
                throws NameNotFoundException { 
            assertNotNull(name);
            MoreAsserts.assertNotEqual(name, "");
            switch (mSearchablesMode) {
            case SEARCHABLES_PASSTHROUGH:
                return mRealPackageManager.getActivityInfo(name, flags);
            case SEARCHABLES_MOCK_ZERO:
                throw new NameNotFoundException();
            default: 
                throw new UnsupportedOperationException();
            } 
        } 
    } 
} 
 
5
CodeRank
This code example shows how to use the following methods:getActivityInfo
            ComponentName name) {
        if (pkgManager == null)
            return null; 
 
        try { 
            ActivityInfo activityInfo = pkgManager.getActivityInfo(name, 0);
            if (activityInfo == null)
                return null; 
 
            return activityInfo;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        } 
 
        return null; 
    } 
 
    public static String getActivityLabel(Context context, ComponentName name) {
        PackageManager pkgManager = context.getPackageManager();
        if (pkgManager == null)
4
CodeRank
This code example shows how to use the following methods:getActivityInfo

Related PackageManager getActivityInfo Questions & Answers:

getActivityInfo Method Overview
Retrieve all of the information we know about a particular activity class.
See Code Examples for other Android PackageManager Methods: