Android ActivityInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ActivityInfo class.

This code example shows how to use the following methods:
This code example shows how to use the following methods:
  @Test 
  public void removeResolveInfosForIntent_shouldCauseResolveActivityToReturnNull() throws Exception { 
    Intent intent = new Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER);
    ResolveInfo info = new ResolveInfo();
    info.nonLocalizedLabel = TEST_PACKAGE_LABEL;
    info.activityInfo = new ActivityInfo();
    info.activityInfo.packageName = "com.org";
    rpm.addResolveInfoForIntent(intent, info);
 
    rpm.removeResolveInfosForIntent(intent, "com.org");
 
    assertThat(rpm.resolveActivity(intent, 0)).isNull();
  } 
 
  @Test 
  public void resolveService__NoMatch() throws Exception { 
    Intent i = new Intent();
    i.setComponent(new ComponentName("foo.bar", "No Activity"));
    assertThat(rpm.resolveService(i, 0)).isNull();
  } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:loadLabel
                View convertView, ViewGroup parent) {
            TextView textView = getGenericView();
            ActivityInfo activity=getChild(groupPosition, childPosition);
            if(activity!=null){
	            String name=activity.name.replace(activity.packageName, "");
	        	textView.setText(activity.loadLabel(mPackageManager)+"("+name+")");
	        	textView.setLayoutParams(lpChild);
            } 
            return textView;
        } 
        public PackageInfo getGroup(int groupPosition) {
        	return groups.get(groupPosition);
        } 
        public int getGroupCount() { 
        	return groups.size();
        } 
        public long getGroupId(int groupPosition) {
            return groupPosition;
        } 
        public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    @Test 
    public void removeResolveInfosForIntent_shouldCauseResolveActivityToReturnNull() throws Exception { 
        Intent intent = new Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER);
        ResolveInfo info = new ResolveInfo();
        info.nonLocalizedLabel = TEST_PACKAGE_LABEL;
        info.activityInfo = new ActivityInfo();
        info.activityInfo.packageName = "com.org";
        rpm.addResolveInfoForIntent(intent, info);
 
        rpm.removeResolveInfosForIntent(intent, "com.org");
 
        assertThat(rpm.resolveActivity(intent, 0)).isNull();
    } 
 
    @Test 
    public void resolveService__NoMatch() throws Exception { 
        Intent i = new Intent();
        i.setComponent(new ComponentName("foo.bar", "No Activity"));
        assertThat(rpm.resolveService(i, 0)).isNull();
    } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:loadLabel
        PackageManager pm = mParent.getPackageManager();
        ActivityInfo ai = intent.resolveActivityInfo(pm, PackageManager.GET_ACTIVITIES);
        String friendlyName = null;
 
        if (ai != null) {
            friendlyName = ai.loadLabel(pm).toString();
            if (friendlyName == null && !labelOnly) {
                friendlyName = ai.name;
            } 
        } 
 
        return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0);
    } 
 
    private String getFriendlyShortcutName(Intent intent) {
        String activityName = getFriendlyActivityName(intent, true);
        String name = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
 
        if (activityName != null && name != null) {
            return activityName + ": " + name;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:loadLabel
 
    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; 
        } else { 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:loadLabel
        PackageManager pm = mParent.getActivity().getPackageManager();
        ActivityInfo ai = intent.resolveActivityInfo(pm, PackageManager.GET_ACTIVITIES);
        String friendlyName = null;
 
        if (ai != null) {
            friendlyName = ai.loadLabel(pm).toString();
            if (friendlyName == null && !labelOnly) {
                friendlyName = ai.name;
            } 
        } 
 
        return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0);
    } 
 
    private String getFriendlyShortcutName(Intent intent) {
        String activityName = getFriendlyActivityName(intent, true);
        String name = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
 
        if (activityName != null && name != null) {
            return activityName + ": " + name;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	 * @return 
	 */ 
	public static ResolveInfo newResolveInfo( String displayName, String packageName ) {
			 
		ResolveInfo resInfo = new ResolveInfo();
		ActivityInfo actInfo = new ActivityInfo();
		actInfo.packageName = packageName;
		resInfo.activityInfo = actInfo;
		 
		ShadowResolveInfo shResolve = Robolectric.shadowOf(resInfo );
		shResolve.setLabel( displayName );
		return resInfo;
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:callAttach
                                                      .getPackage() 
                                                      .getName(), mActivity.getClass()
                                                                           .getName()); 
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setComponent(cn);
        ActivityInfo info = new ActivityInfo();
        CharSequence title = mActivity.getClass()
                                      .getName(); 
        mMockParent = new MockParent();
        String id = null;
        ActivityTrojanHorse.callAttach(getInstrumentation(), mActivity, mFragmentContext, token, mApplication, intent, info, title, mMockParent, id, lastNonConfigurationInstance);
 
        mActivityAttached = true;
    } 
 
    /* 
     * (non-Javadoc) 
     *  
     * @see android.test.InstrumentationTestCase#tearDown() 
     */ 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:loadLabel
        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; 
        } 
    } 
 
    private String getDialogMessage(boolean isOutOfMemory, int index) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android ActivityInfo Questions & Answers:

See Code Examples for Android ActivityInfo Methods: