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.QuarkLabs.BTCeClient.UpdateWidgetsTask.java

@Override
protected void onPostExecute(JSONObject jsonObject) {
    if (jsonObject != null) {
        try {/*  w  w  w  .j a va 2 s.c  om*/
            Context context = mContext.get();
            if (context == null) {
                return;
            }
            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
            for (int x : mMap.keySet()) {
                RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_layout);
                double price = jsonObject.getJSONObject(mMap.get(x).replace("/", "_").toLowerCase(Locale.US))
                        .getDouble("last");
                String priceString;
                if (price > 1) {
                    priceString = (new DecimalFormat("#.##")).format(price);
                } else {
                    priceString = String.valueOf(price);
                }
                views.setTextViewText(R.id.widgetCurrencyValue, priceString);
                views.setTextViewText(R.id.widgetPair, mMap.get(x));
                String color = jsonObject.getJSONObject(mMap.get(x).replace("/", "_").toLowerCase(Locale.US))
                        .getString("color");
                int colorValue = color.equals("green") ? Color.GREEN : Color.RED;
                views.setTextColor(R.id.widgetCurrencyValue, colorValue);
                Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
                Bundle bundle = new Bundle();
                bundle.putIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS,
                        appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class)));
                intent.putExtras(bundle);
                PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                views.setOnClickPendingIntent(R.id.widgetContainer, pi);
                SimpleDateFormat df = new SimpleDateFormat("EEE HH:mm", Locale.US);
                Calendar calendar = Calendar.getInstance();
                views.setTextViewText(R.id.widgetDate, df.format(calendar.getTime()));
                appWidgetManager.updateAppWidget(x, views);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.mobilesolutionworks.android.httpcache.HttpCacheLoaderImpl.java

public static Intent createExplicitFromImplicitIntent(Context context, Intent implicitIntent) {
    // Retrieve all services that can match the given intent
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> resolveInfo = pm.queryIntentServices(implicitIntent, 0);

    // Make sure only one match was found
    if (resolveInfo == null || resolveInfo.size() != 1) {
        return null;
    }//from w w w . j a  v a 2s.co m

    // Get component info and create ComponentName
    ResolveInfo serviceInfo = resolveInfo.get(0);
    String packageName = serviceInfo.serviceInfo.packageName;
    String className = serviceInfo.serviceInfo.name;
    ComponentName component = new ComponentName(packageName, className);

    // Create a new intent. Use the old one for extras and such reuse
    Intent explicitIntent = new Intent(implicitIntent);

    // Set the component to be explicit
    explicitIntent.setComponent(component);

    return explicitIntent;
}

From source file:com.phonemetra.account.util.AccountUtils.java

private static Intent getWifiSetupIntent(Context context) {
    Intent intent = new Intent();
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(new ComponentName(Account.WIFI_COMPONENT_PKG, Account.WIFI_COMPONENT_CLASS));
    intent.putExtra(Account.EXTRA_FIRST_RUN, true);
    intent.putExtra(Account.EXTRA_ALLOW_SKIP, false);
    intent.putExtra(Account.EXTRA_SHOW_BUTTON_BAR, true);
    intent.putExtra(Account.EXTRA_ONLY_ACCESS_POINTS, true);
    intent.putExtra(Account.EXTRA_AUTO_FINISH, true);
    return intent;
}

From source file:br.com.bioscada.apps.biotracks.widgets.TrackWidgetProvider.java

/**
 * Updates all app widgets./*w  w w  .j av  a2  s.  c  om*/
 * 
 * @param context the context
 * @param trackId track id
 */
private static void updateAllAppWidgets(Context context, long trackId) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    int[] appWidgetIds = appWidgetManager
            .getAppWidgetIds(new ComponentName(context, TrackWidgetProvider.class));
    for (int appWidgetId : appWidgetIds) {
        updateAppWidget(context, appWidgetManager, appWidgetId, trackId);
    }
}

From source file:com.meiste.greg.ptw.WidgetProvider.java

private int[] getInstalledWidgets(final Context context) {
    final ComponentName thisWidget = new ComponentName(context, WidgetProvider.class);
    final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    return appWidgetManager.getAppWidgetIds(thisWidget);
}

From source file:com.brewcrewfoo.performance.util.Helpers.java

public static void updateAppWidget(Context context) {
    AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
    ComponentName widgetComponent = new ComponentName(context, PCWidget.class);
    int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
    Intent update = new Intent();
    update.setAction("com.brewcrewfoo.performance.ACTION_FREQS_CHANGED");
    update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
    context.sendBroadcast(update);/*from ww  w .  j  a  v a  2s.c  om*/
}

From source file:com.battlelancer.seriesguide.extensions.ExtensionManager.java

/**
 * Enables the default list of extensions that come with this app.
 *//*from  ww  w.j  a va 2  s  . co m*/
public void setDefaultEnabledExtensions() {
    List<ComponentName> defaultExtensions = new ArrayList<>();
    defaultExtensions.add(new ComponentName(mContext, YouTubeExtension.class));
    setEnabledExtensions(defaultExtensions);
}

From source file:androidx.media.SessionToken2.java

/**
 * @hide/*from   w ww. j  a v a 2  s .co  m*/
 */
@RestrictTo(LIBRARY_GROUP)
SessionToken2(int uid, int type, String packageName, String serviceName, String id,
        MediaSessionCompat.Token sessionCompatToken) {
    mUid = uid;
    mType = type;
    mPackageName = packageName;
    mServiceName = serviceName;
    mComponentName = (mType == TYPE_SESSION) ? null : new ComponentName(packageName, serviceName);
    mId = id;
    mSessionCompatToken = sessionCompatToken;
}

From source file:co.edu.uniajc.vtf.ar.ARViewActivity.java

@Override
protected void onPause() {
    super.onPause();
    ComponentName loComponent = new ComponentName(this, NetworkStatusReceiver.class);
    this.getPackageManager().setComponentEnabledSetting(loComponent,
            PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    LocationServices.FusedLocationApi.removeLocationUpdates(coGoogleApiClient, this);
    if (this.architectView != null) {
        this.architectView.onPause();
    }// w ww .j  a va2  s. com
}

From source file:com.android.usbtuner.setup.TunerSetupActivity.java

/**
 * Returns a {@link Intent} to launch the USB tuner TV input service.
 *
 * @param context a {@link Context} instance
 *//* w  ww. jav a 2s .co  m*/
public static Intent createSetupActivity(Context context) {
    String inputId = TvContract
            .buildInputId(new ComponentName(context.getPackageName(), UsbTunerTvInputService.class.getName()));

    // Make an intent to launch the setup activity of USB tuner TV input.
    Intent intent = TvCommonUtils.createSetupIntent(new Intent(context, TunerSetupActivity.class), inputId);
    intent.putExtra(TvCommonConstants.EXTRA_INPUT_ID, inputId);
    Intent tvActivityIntent = new Intent();
    tvActivityIntent.setComponent(new ComponentName(context, TV_ACTIVITY_CLASS_NAME));
    intent.putExtra(TvCommonConstants.EXTRA_ACTIVITY_AFTER_COMPLETION, tvActivityIntent);
    return intent;
}