Search in sources :

Example 96 with ComponentName

use of android.content.ComponentName in project AsmackService by rtreffer.

the class SyncAdapter method bindService.

/**
     * Bind to the xmpp transport service.
     */
private final synchronized void bindService() {
    if (serviceConnection == null) {
        XmppTransportService.start(applicationContext);
        serviceConnection = new ServiceConnection() {

            public void onServiceDisconnected(ComponentName name) {
            }

            public void onServiceConnected(ComponentName name, IBinder binder) {
                service = IXmppTransportService.Stub.asInterface(binder);
            }
        };
    }
    applicationContext.bindService(new Intent(IXmppTransportService.class.getName()), serviceConnection, Context.BIND_AUTO_CREATE);
}
Also used : ServiceConnection(android.content.ServiceConnection) IBinder(android.os.IBinder) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 97 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class TestInteractionActivity method onClick.

@Override
public void onClick(View v) {
    if (v == mAirplaneButton) {
        Intent intent = new Intent(Settings.ACTION_VOICE_CONTROL_AIRPLANE_MODE);
        intent.addCategory(Intent.CATEGORY_VOICE);
        intent.putExtra(Settings.EXTRA_AIRPLANE_MODE_ENABLED, true);
        startActivity(intent);
    } else if (v == mAbortButton) {
        VoiceInteractor.AbortVoiceRequest req = new TestAbortVoice();
        mInteractor.submitRequest(req, REQUEST_ABORT);
    } else if (v == mCompleteButton) {
        VoiceInteractor.CompleteVoiceRequest req = new TestCompleteVoice();
        mInteractor.submitRequest(req, REQUEST_COMPLETE);
    } else if (v == mCommandButton) {
        VoiceInteractor.CommandRequest req = new TestCommand("Some arg");
        mInteractor.submitRequest(req, REQUEST_COMMAND);
    } else if (v == mPickButton) {
        VoiceInteractor.PickOptionRequest.Option[] options = new VoiceInteractor.PickOptionRequest.Option[5];
        options[0] = new VoiceInteractor.PickOptionRequest.Option("One");
        options[1] = new VoiceInteractor.PickOptionRequest.Option("Two");
        options[2] = new VoiceInteractor.PickOptionRequest.Option("Three");
        options[3] = new VoiceInteractor.PickOptionRequest.Option("Four");
        options[4] = new VoiceInteractor.PickOptionRequest.Option("Five");
        VoiceInteractor.PickOptionRequest req = new TestPickOption(options);
        mInteractor.submitRequest(req, REQUEST_PICK);
    } else if (v == mJumpOutButton) {
        Log.i(TAG, "Jump out");
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setComponent(new ComponentName(this, VoiceInteractionMain.class));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    } else if (v == mCancelButton && mCurrentRequest != null) {
        Log.i(TAG, "Cancel request");
        mCurrentRequest.cancel();
    }
}
Also used : Intent(android.content.Intent) ComponentName(android.content.ComponentName) VoiceInteractor(android.app.VoiceInteractor)

Example 98 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class TestAppWidgetProvider method onReceive.

public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.d(TAG, "intent=" + intent);
    if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)) {
        Log.d(TAG, "ENABLED");
    } else if (AppWidgetManager.ACTION_APPWIDGET_DISABLED.equals(action)) {
        Log.d(TAG, "DISABLED");
    } else if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
        Log.d(TAG, "UPDATE");
        // BEGIN_INCLUDE(getExtra_EXTRA_APPWIDGET_IDS)
        Bundle extras = intent.getExtras();
        int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
        // END_INCLUDE(getExtra_EXTRA_APPWIDGET_IDS)
        SharedPreferences prefs = context.getSharedPreferences(TestAppWidgetProvider.PREFS_NAME, 0);
        String prefix = prefs.getString(PREF_PREFIX_KEY, "hai");
        AppWidgetManager gm = AppWidgetManager.getInstance(context);
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.test_appwidget);
        views.setTextViewText(R.id.oh_hai_text, prefix + ": " + SystemClock.elapsedRealtime());
        if (false) {
            gm.updateAppWidget(appWidgetIds, views);
        } else {
            gm.updateAppWidget(new ComponentName("com.android.tests.appwidgethost", "com.android.tests.appwidgethost.TestAppWidgetProvider"), views);
        }
    }
}
Also used : RemoteViews(android.widget.RemoteViews) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentName(android.content.ComponentName)

Example 99 with ComponentName

use of android.content.ComponentName in project platform_packages_apps_launcher by android.

the class Workspace method updateShortcutsForPackage.

void updateShortcutsForPackage(String packageName) {
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final CellLayout layout = (CellLayout) getChildAt(i);
        int childCount = layout.getChildCount();
        for (int j = 0; j < childCount; j++) {
            final View view = layout.getChildAt(j);
            Object tag = view.getTag();
            if (tag instanceof ApplicationInfo) {
                ApplicationInfo info = (ApplicationInfo) tag;
                // We need to check for ACTION_MAIN otherwise getComponent() might
                // return null for some shortcuts (for instance, for shortcuts to
                // web pages.)
                final Intent intent = info.intent;
                final ComponentName name = intent.getComponent();
                if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && Intent.ACTION_MAIN.equals(intent.getAction()) && name != null && packageName.equals(name.getPackageName())) {
                    final Drawable icon = Launcher.getModel().getApplicationInfoIcon(mLauncher.getPackageManager(), info);
                    if (icon != null && icon != info.icon) {
                        info.icon.setCallback(null);
                        info.icon = Utilities.createIconThumbnail(icon, mContext);
                        info.filtered = true;
                        ((TextView) view).setCompoundDrawablesWithIntrinsicBounds(null, info.icon, null, null);
                    }
                }
            }
        }
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) Intent(android.content.Intent) ComponentName(android.content.ComponentName) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) Paint(android.graphics.Paint)

Example 100 with ComponentName

use of android.content.ComponentName in project platform_packages_apps_launcher by android.

the class LauncherModel method updateShortcutLabels.

private static void updateShortcutLabels(ContentResolver resolver, PackageManager manager) {
    final Cursor c = resolver.query(LauncherSettings.Favorites.CONTENT_URI, new String[] { LauncherSettings.Favorites._ID, LauncherSettings.Favorites.TITLE, LauncherSettings.Favorites.INTENT, LauncherSettings.Favorites.ITEM_TYPE }, null, null, null);
    final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);
    final int intentIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.INTENT);
    final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);
    final int titleIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE);
    try {
        while (c.moveToNext()) {
            try {
                if (c.getInt(itemTypeIndex) != LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
                    continue;
                }
                final String intentUri = c.getString(intentIndex);
                if (intentUri != null) {
                    final Intent shortcut = Intent.parseUri(intentUri, 0);
                    if (Intent.ACTION_MAIN.equals(shortcut.getAction())) {
                        final ComponentName name = shortcut.getComponent();
                        if (name != null) {
                            final ActivityInfo activityInfo = manager.getActivityInfo(name, 0);
                            final String title = c.getString(titleIndex);
                            String label = getLabel(manager, activityInfo);
                            if (title == null || !title.equals(label)) {
                                final ContentValues values = new ContentValues();
                                values.put(LauncherSettings.Favorites.TITLE, label);
                                resolver.update(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values, "_id=?", new String[] { String.valueOf(c.getLong(idIndex)) });
                            // changed = true;
                            }
                        }
                    }
                }
            } catch (URISyntaxException e) {
            // Ignore
            } catch (PackageManager.NameNotFoundException e) {
            // Ignore
            }
        }
    } finally {
        c.close();
    }
// if (changed) resolver.notifyChange(Settings.Favorites.CONTENT_URI, null);
}
Also used : ContentValues(android.content.ContentValues) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) ComponentName(android.content.ComponentName) URISyntaxException(java.net.URISyntaxException) Cursor(android.database.Cursor)

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