Example usage for android.content ComponentName ComponentName

List of usage examples for android.content ComponentName ComponentName

Introduction

In this page you can find the example usage for android.content ComponentName ComponentName.

Prototype

private ComponentName(String pkg, Parcel in) 

Source Link

Usage

From source file:com.thejoshwa.ultrasonic.androidapp.util.Util.java

public static void unregisterMediaButtonEventReceiver(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    audioManager.unregisterMediaButtonEventReceiver(
            new ComponentName(context.getPackageName(), MediaButtonIntentReceiver.class.getName()));
}

From source file:com.aujur.ebookreader.activity.ReadingFragment.java

@TargetApi(Build.VERSION_CODES.FROYO)
private void subscribeToMediaButtons() {
    if (this.mediaReceiver == null) {
        this.mediaReceiver = new PageTurnerMediaReceiver();
        IntentFilter filter = new IntentFilter(MediaButtonReceiver.INTENT_PAGETURNER_MEDIA);
        context.registerReceiver(mediaReceiver, filter);

        audioManager.registerMediaButtonEventReceiver(new ComponentName(context, MediaButtonReceiver.class));
    }// ww w.ja va 2s .  c  om
}

From source file:com.android.documentsui.DocumentsActivity.java

public void onAppPicked(ResolveInfo info) {
    final Intent intent = new Intent(getIntent());
    intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT);
    intent.setComponent(/*w ww. ja  v a  2  s  . co m*/
            new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name));
    startActivityForResult(intent, CODE_FORWARD);
}

From source file:com.aujur.ebookreader.activity.ReadingFragment.java

@TargetApi(Build.VERSION_CODES.FROYO)
private void unsubscribeFromMediaButtons() {
    if (this.mediaReceiver != null) {
        context.unregisterReceiver(mediaReceiver);
        this.mediaReceiver = null;

        audioManager.unregisterMediaButtonEventReceiver(new ComponentName(context, MediaButtonReceiver.class));
    }/*from   w w  w  . j a  v a  2 s . c  o m*/
}

From source file:com.linkbubble.Settings.java

public Drawable getConsumeBubbleIcon(Constant.BubbleAction action, boolean whiteShareIcon) {
    PackageManager packageManager = mContext.getPackageManager();
    try {/*ww w  .ja  v a 2  s  .  co  m*/
        String packageName = getConsumeBubblePackageName(action);
        String name = getConsumeBubbleActivityClassName(action);
        if (packageName != null && name != null) {
            if (name.equals(Constant.SHARE_PICKER_NAME)) {
                return mContext.getResources().getDrawable(
                        whiteShareIcon ? R.drawable.ic_share_white_24dp : R.drawable.ic_share_grey600_24dp);
            }
            ComponentName componentName = new ComponentName(packageName, name);
            return packageManager.getActivityIcon(componentName);
        } else if (packageName != null) {
            // Try rendering the icon if we only have a packageName.
            ApplicationInfo app = packageManager.getApplicationInfo(packageName, 0);
            Drawable icon = packageManager.getApplicationIcon(app);
            return icon;
        }
    } catch (OutOfMemoryError ex) {
    } catch (PackageManager.NameNotFoundException e) {
    }
    return mContext.getResources().getDrawable(R.drawable.ic_launcher);
}

From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java

public void onAppPicked(ResolveInfo info) {
    final Intent intent = new Intent(virtualIntent);
    intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT);
    intent.setComponent(/*from  w  w  w .j a  va  2  s. c o  m*/
            new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name));
    startActivityForResult(intent, CODE_FORWARD);
}

From source file:com.csipsimple.ui.SipHome.java

private void disconnect(boolean quit) {
    Log.d(THIS_FILE, "True disconnection...");
    Intent intent = new Intent(SipManager.ACTION_OUTGOING_UNREGISTER);
    intent.putExtra(SipManager.EXTRA_OUTGOING_ACTIVITY, new ComponentName(this, SipHome.class));
    sendBroadcast(intent);/* w w  w .  j  a v a 2 s.co m*/
    if (quit) {
        finish();
    }
}

From source file:github.daneren2005.dsub.util.Util.java

private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean playing) {

    // Use the same text for the ticker and the expanded notification
    String title = song.getTitle();
    String arist = song.getArtist();
    String album = song.getAlbum();

    // Set the album art.
    try {//  ww  w.  jav  a2 s .c  o  m
        int size = context.getResources().getDrawable(R.drawable.unknown_album).getIntrinsicHeight();
        Bitmap bitmap = FileUtil.getAlbumArtBitmap(context, song, size);
        if (bitmap == null) {
            // set default album art
            rv.setImageViewResource(R.id.notification_image, R.drawable.unknown_album);
        } else {
            rv.setImageViewBitmap(R.id.notification_image, bitmap);
        }
    } catch (Exception x) {
        Log.w(TAG, "Failed to get notification cover art", x);
        rv.setImageViewResource(R.id.notification_image, R.drawable.unknown_album);
    }

    // set the text for the notifications
    rv.setTextViewText(R.id.notification_title, title);
    rv.setTextViewText(R.id.notification_artist, arist);
    rv.setTextViewText(R.id.notification_album, album);

    Pair<Integer, Integer> colors = getNotificationTextColors(context);
    if (colors.getFirst() != null) {
        rv.setTextColor(R.id.notification_title, colors.getFirst());
    }
    if (colors.getSecond() != null) {
        rv.setTextColor(R.id.notification_artist, colors.getSecond());
    }

    if (!playing) {
        rv.setImageViewResource(R.id.control_pause, R.drawable.notification_play);
        rv.setImageViewResource(R.id.control_previous, R.drawable.notification_stop);
    }

    // Create actions for media buttons
    PendingIntent pendingIntent;
    if (playing) {
        Intent prevIntent = new Intent("KEYCODE_MEDIA_PREVIOUS");
        prevIntent.setComponent(new ComponentName(context, DownloadServiceImpl.class));
        prevIntent.putExtra(Intent.EXTRA_KEY_EVENT,
                new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PREVIOUS));
        pendingIntent = PendingIntent.getService(context, 0, prevIntent, 0);
        rv.setOnClickPendingIntent(R.id.control_previous, pendingIntent);
    } else {
        Intent prevIntent = new Intent("KEYCODE_MEDIA_STOP");
        prevIntent.setComponent(new ComponentName(context, DownloadServiceImpl.class));
        prevIntent.putExtra(Intent.EXTRA_KEY_EVENT,
                new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_STOP));
        pendingIntent = PendingIntent.getService(context, 0, prevIntent, 0);
        rv.setOnClickPendingIntent(R.id.control_previous, pendingIntent);
    }

    Intent pauseIntent = new Intent("KEYCODE_MEDIA_PLAY_PAUSE");
    pauseIntent.setComponent(new ComponentName(context, DownloadServiceImpl.class));
    pauseIntent.putExtra(Intent.EXTRA_KEY_EVENT,
            new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
    pendingIntent = PendingIntent.getService(context, 0, pauseIntent, 0);
    rv.setOnClickPendingIntent(R.id.control_pause, pendingIntent);

    Intent nextIntent = new Intent("KEYCODE_MEDIA_NEXT");
    nextIntent.setComponent(new ComponentName(context, DownloadServiceImpl.class));
    nextIntent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT));
    pendingIntent = PendingIntent.getService(context, 0, nextIntent, 0);
    rv.setOnClickPendingIntent(R.id.control_next, pendingIntent);
}

From source file:cc.mintcoin.wallet.service.BlockchainServiceImpl.java

public void notifyWidgets() {
    final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);

    final ComponentName providerName = new ComponentName(this, WalletBalanceWidgetProvider.class);

    try {//from ww w .  j a va2 s. co  m
        final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(providerName);

        if (appWidgetIds.length > 0) {
            final Wallet wallet = application.getWallet();
            final BigInteger balance = wallet.getBalance(BalanceType.ESTIMATED);

            WalletBalanceWidgetProvider.updateWidgets(this, appWidgetManager, appWidgetIds, balance);
        }
    } catch (final RuntimeException x) // system server dead?
    {
        log.warn("cannot update app widgets", x);
    }
}

From source file:org.openintents.shopping.ui.ShoppingActivity.java

private void updateWidgets() {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
    int[] a = appWidgetManager
            .getAppWidgetIds(new ComponentName(this.getPackageName(), CheckItemsWidget.class.getName()));
    List<AppWidgetProviderInfo> b = appWidgetManager.getInstalledProviders();
    for (AppWidgetProviderInfo i : b) {
        if (i.provider.getPackageName().equals(this.getPackageName())) {
            a = appWidgetManager.getAppWidgetIds(i.provider);
            new CheckItemsWidget().onUpdate(this, appWidgetManager, a);
        }/*from   w w w  .  j a va 2 s.  c  o m*/
    }
}