Search in sources :

Example 1 with ComponentName

use of android.content.ComponentName in project Launcher3 by chislon.

the class MemoryDumpActivity method startDump.

public static void startDump(final Context context, final Runnable andThen) {
    final ServiceConnection connection = new ServiceConnection() {

        public void onServiceConnected(ComponentName className, IBinder service) {
            Log.v(TAG, "service connected, dumping...");
            dumpHprofAndShare(context, ((MemoryTracker.MemoryTrackerInterface) service).getService());
            context.unbindService(this);
            if (andThen != null)
                andThen.run();
        }

        public void onServiceDisconnected(ComponentName className) {
        }
    };
    Log.v(TAG, "attempting to bind to memory tracker");
    context.bindService(new Intent(context, MemoryTracker.class), connection, Context.BIND_AUTO_CREATE);
}
Also used : ServiceConnection(android.content.ServiceConnection) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 2 with ComponentName

use of android.content.ComponentName in project Launcher3 by chislon.

the class Workspace method updateShortcuts.

void updateShortcuts(ArrayList<AppInfo> apps) {
    ArrayList<ShortcutAndWidgetContainer> childrenLayouts = getAllShortcutAndWidgetContainers();
    for (ShortcutAndWidgetContainer layout : childrenLayouts) {
        int childCount = layout.getChildCount();
        for (int j = 0; j < childCount; j++) {
            final View view = layout.getChildAt(j);
            Object tag = view.getTag();
            if (LauncherModel.isShortcutInfoUpdateable((ItemInfo) tag)) {
                ShortcutInfo info = (ShortcutInfo) tag;
                final Intent intent = info.intent;
                final ComponentName name = intent.getComponent();
                final int appCount = apps.size();
                for (int k = 0; k < appCount; k++) {
                    AppInfo app = apps.get(k);
                    if (app.componentName.equals(name)) {
                        BubbleTextView shortcut = (BubbleTextView) view;
                        info.updateIcon(mIconCache);
                        info.title = app.title.toString();
                        shortcut.applyFromShortcutInfo(info, mIconCache);
                    }
                }
            }
        }
    }
}
Also used : Intent(android.content.Intent) ComponentName(android.content.ComponentName) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) Point(android.graphics.Point)

Example 3 with ComponentName

use of android.content.ComponentName in project cw-omnibus by commonsguy.

the class Plugin method onReceive.

@Override
public void onReceive(Context ctxt, Intent i) {
    if (ACTION_CALL_FOR_PLUGINS.equals(i.getAction())) {
        Intent registration = new Intent(ACTION_REGISTER_PLUGIN);
        registration.setPackage(HOST_PACKAGE);
        registration.putExtra(EXTRA_COMPONENT, new ComponentName(ctxt, getClass()));
        ctxt.sendBroadcast(registration);
    } else if (ACTION_CALL_FOR_CONTENT.equals(i.getAction())) {
        RemoteViews rv = new RemoteViews(ctxt.getPackageName(), R.layout.plugin);
        Intent update = new Intent(ACTION_DELIVER_CONTENT);
        update.setPackage(HOST_PACKAGE);
        update.putExtra(EXTRA_CONTENT, rv);
        ctxt.sendBroadcast(update);
    }
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 4 with ComponentName

use of android.content.ComponentName in project cw-omnibus by commonsguy.

the class EventDemoActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getFragmentManager().findFragmentById(android.R.id.content) == null) {
        getFragmentManager().beginTransaction().add(android.R.id.content, new EventLogFragment()).commit();
        JobScheduler jobs = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
        ComponentName cn = new ComponentName(this, ScheduledService.class);
        JobInfo.Builder b = new JobInfo.Builder(JOB_ID, cn).setRequiredNetworkType(JobInfo.NETWORK_TYPE_NONE).setPeriodic(60000).setPersisted(false).setRequiresCharging(false).setRequiresDeviceIdle(false);
        jobs.schedule(b.build());
    }
}
Also used : JobScheduler(android.app.job.JobScheduler) JobInfo(android.app.job.JobInfo) ComponentName(android.content.ComponentName)

Example 5 with ComponentName

use of android.content.ComponentName in project Launcher3 by chislon.

the class LauncherTransitionable method updateVoiceSearchIcon.

protected boolean updateVoiceSearchIcon(boolean searchVisible) {
    final View voiceButtonContainer = findViewById(R.id.voice_button_container);
    final View voiceButton = findViewById(R.id.voice_button);
    // We only show/update the voice search icon if the search icon is enabled as well
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
    ComponentName activityName = null;
    if (globalSearchActivity != null) {
        // Check if the global search activity handles voice search
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        intent.setPackage(globalSearchActivity.getPackageName());
        activityName = intent.resolveActivity(getPackageManager());
    }
    if (activityName == null) {
        // Fallback: check if an activity other than the global search activity
        // resolves this
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        activityName = intent.resolveActivity(getPackageManager());
    }
    if (searchVisible && activityName != null) {
        int coi = getCurrentOrientationIndexForGlobalIcons();
        sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName, R.drawable.ic_home_voice_search_holo, TOOLBAR_VOICE_SEARCH_ICON_METADATA_NAME);
        if (sVoiceSearchIcon[coi] == null) {
            sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName, R.drawable.ic_home_voice_search_holo, TOOLBAR_ICON_METADATA_NAME);
        }
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.VISIBLE);
        voiceButton.setVisibility(View.VISIBLE);
        updateVoiceButtonProxyVisible(false);
        invalidatePressedFocusedStates(voiceButtonContainer, voiceButton);
        return true;
    } else {
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.GONE);
        if (voiceButton != null)
            voiceButton.setVisibility(View.GONE);
        updateVoiceButtonProxyVisible(false);
        return false;
    }
}
Also used : SearchManager(android.app.SearchManager) ComponentName(android.content.ComponentName) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) Point(android.graphics.Point)

Aggregations

ComponentName (android.content.ComponentName)2524 Intent (android.content.Intent)941 ResolveInfo (android.content.pm.ResolveInfo)375 RemoteException (android.os.RemoteException)317 PackageManager (android.content.pm.PackageManager)266 PendingIntent (android.app.PendingIntent)248 ActivityInfo (android.content.pm.ActivityInfo)243 ArrayList (java.util.ArrayList)240 ShortcutInfo (android.content.pm.ShortcutInfo)152 Point (android.graphics.Point)145 Bundle (android.os.Bundle)137 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)130 IBinder (android.os.IBinder)128 IOException (java.io.IOException)124 ServiceConnection (android.content.ServiceConnection)96 ServiceInfo (android.content.pm.ServiceInfo)95 UserHandle (android.os.UserHandle)86 ArraySet (android.util.ArraySet)73 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Uri (android.net.Uri)66