Search in sources :

Example 21 with ComponentName

use of android.content.ComponentName in project VirtualApp by asLody.

the class VPackageManagerService method queryIntentContentProviders.

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public List<ResolveInfo> queryIntentContentProviders(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ProviderInfo pi = getProviderInfo(comp, flags, userId);
        if (pi != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.providerInfo = pi;
            list.add(ri);
        }
        return list;
    }
    // reader
    synchronized (mPackages) {
        String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mProviders.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers, userId);
        }
        return null;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) VPackage(com.lody.virtual.server.pm.parser.VPackage) ProviderInfo(android.content.pm.ProviderInfo) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) TargetApi(android.annotation.TargetApi)

Example 22 with ComponentName

use of android.content.ComponentName in project VirtualApp by asLody.

the class VPackageManagerService method queryIntentReceivers.

@Override
public List<ResolveInfo> queryIntentReceivers(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        ActivityInfo ai = getReceiverInfo(comp, flags, userId);
        if (ai != null) {
            ResolveInfo ri = new ResolveInfo();
            ri.activityInfo = ai;
            list.add(ri);
        }
        return list;
    }
    // reader
    synchronized (mPackages) {
        String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mReceivers.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mReceivers.queryIntentForPackage(intent, resolvedType, flags, pkg.receivers, userId);
        }
        return null;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) VPackage(com.lody.virtual.server.pm.parser.VPackage) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName)

Example 23 with ComponentName

use of android.content.ComponentName in project Talon-for-Twitter by klinker24.

the class TouchableSpan method onClick.

@Override
public void onClick(View widget) {
    if (Patterns.WEB_URL.matcher(mValue).find()) {
        String url = "http://" + full.replace("http://", "").replace("https://", "").replace("\"", "");
        new WebIntentBuilder(mContext).setUrl(url).setShouldForceExternal(extBrowser).build().start();
    } else if (Regex.HASHTAG_PATTERN.matcher(mValue).find()) {
        // found a hashtag, so open the hashtag search
        Intent search;
        if (!fromLauncher) {
            search = new Intent(mContext, SearchedTrendsActivity.class);
        } else {
            search = new Intent("android.intent.action.MAIN");
            search.setComponent(new ComponentName("com.klinker.android.twitter", "com.klinker.android.twitter.ui.drawer_activities.discover.trends.LauncherSearchedTrends"));
            search.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            search.putExtra("current_account", settings.currentAccount);
        }
        search.setAction(Intent.ACTION_SEARCH);
        search.putExtra(SearchManager.QUERY, full);
        mContext.startActivity(search);
    } else if (Regex.MENTION_PATTERN.matcher(mValue).find()) {
        Intent user;
        if (!fromLauncher) {
            user = new Intent(mContext, ProfilePager.class);
        } else {
            user = new Intent("android.intent.action.MAIN");
            user.setComponent(new ComponentName("com.klinker.android.twitter", "com.klinker.android.twitter.ui.profile_viewer.LauncherProfilePager"));
            user.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            user.putExtra("current_account", settings.currentAccount);
        }
        user.putExtra("screenname", full.replace("@", "").replaceAll(" ", ""));
        user.putExtra("proPic", "");
        mContext.startActivity(user);
    } else if (Regex.CASHTAG_PATTERN.matcher(mValue).find()) {
        // found a cashtag, so open the search
        Intent search;
        if (!fromLauncher) {
            search = new Intent(mContext, SearchedTrendsActivity.class);
        } else {
            search = new Intent("android.intent.action.MAIN");
            search.setComponent(new ComponentName("com.klinker.android.twitter", "com.klinker.android.twitter.ui.drawer_activities.discover.trends.LauncherSearchedTrends"));
            search.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            search.putExtra("current_account", settings.currentAccount);
        }
        search.setAction(Intent.ACTION_SEARCH);
        search.putExtra(SearchManager.QUERY, full);
        mContext.startActivity(search);
    }
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            TouchableMovementMethod.touched = false;
        }
    }, 500);
}
Also used : WebIntentBuilder(com.klinker.android.twitter.utils.WebIntentBuilder) ProfilePager(com.klinker.android.twitter.activities.profile_viewer.ProfilePager) Handler(android.os.Handler) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 24 with ComponentName

use of android.content.ComponentName in project Lazy by l123456789jy.

the class AppUtils method isApplicationInBackground.

/**
     * whether application is in background
     * <ul>
     * <li>need use permission android.permission.GET_TASKS in Manifest.xml</li>
     * </ul>
     *
     * @param context 上下文
     * @return if application is in background return true, otherwise return
     * false
     */
public static boolean isApplicationInBackground(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningTaskInfo> taskList = am.getRunningTasks(1);
    if (taskList != null && !taskList.isEmpty()) {
        ComponentName topActivity = taskList.get(0).topActivity;
        if (topActivity != null && !topActivity.getPackageName().equals(context.getPackageName())) {
            return true;
        }
    }
    return false;
}
Also used : ComponentName(android.content.ComponentName) ActivityManager(android.app.ActivityManager) RunningTaskInfo(android.app.ActivityManager.RunningTaskInfo)

Example 25 with ComponentName

use of android.content.ComponentName in project goro by stanfy.

the class BaseBindingGoroTest method init.

@Before
public void init() {
    context = Robolectric.setupActivity(Activity.class);
    shadowContext = Shadows.shadowOf(context);
    testingQueues = new TestingQueues();
    serviceInstance = spy(new Goro.GoroImpl(testingQueues));
    serviceCompName = new ComponentName(context, GoroService.class);
    GoroService service = new GoroService();
    binder = new GoroService.GoroBinderImpl(serviceInstance, service.new GoroTasksListener());
    ShadowApplication.getInstance().setComponentNameAndServiceForBindService(serviceCompName, binder);
    reset(serviceInstance);
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Activity(android.app.Activity) ComponentName(android.content.ComponentName) Before(org.junit.Before)

Aggregations

ComponentName (android.content.ComponentName)2548 Intent (android.content.Intent)959 ResolveInfo (android.content.pm.ResolveInfo)375 RemoteException (android.os.RemoteException)317 PackageManager (android.content.pm.PackageManager)269 PendingIntent (android.app.PendingIntent)252 ActivityInfo (android.content.pm.ActivityInfo)243 ArrayList (java.util.ArrayList)242 ShortcutInfo (android.content.pm.ShortcutInfo)152 Point (android.graphics.Point)145 Bundle (android.os.Bundle)139 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)132 IBinder (android.os.IBinder)128 IOException (java.io.IOException)125 ServiceConnection (android.content.ServiceConnection)96 ServiceInfo (android.content.pm.ServiceInfo)96 UserHandle (android.os.UserHandle)86 ArraySet (android.util.ArraySet)73 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Uri (android.net.Uri)68