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.chale22.ico01.fragments.FragmentTheme.java

private void applyAdwTheme() {
    try {//from w  w  w .j a  v a 2s. c o m
        Intent adwlauncherIntent = new Intent(Intent.ACTION_MAIN);
        adwlauncherIntent.setComponent(new ComponentName("org.adw.launcher", "org.adw.launcher.Launcher"));
        startActivity(adwlauncherIntent);
        makeToast("Apply with \"ADW Settings\" in Menu");
    } catch (ActivityNotFoundException e4) {
        e4.printStackTrace();
        makeToast("ADW Launcher is not installed!");
    }

}

From source file:de.Maxr1998.xposed.maxlock.ui.settings.SettingsFragment.java

@SuppressLint("WorldReadableFiles")
@Override//from w  ww. j a va 2 s  .co m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    //noinspection deprecation
    getPreferenceManager().setSharedPreferencesMode(Activity.MODE_WORLD_READABLE);
    addPreferencesFromResource(R.xml.preferences_main);
    PREFS = PreferenceManager.getDefaultSharedPreferences(getActivity());
    PREFS_KEYS = getActivity().getSharedPreferences(Common.PREFS_KEY, Context.MODE_PRIVATE);
    //noinspection deprecation
    PREFS_THEME = getActivity().getSharedPreferences(Common.PREFS_THEME, Context.MODE_WORLD_READABLE);

    devicePolicyManager = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
    deviceAdmin = new ComponentName(getActivity(), UninstallProtectionReceiver.class);
}

From source file:com.emotion.emotioncontrol.MainActivity.java

public boolean isLauncherIconEnabled() {
    PackageManager p = getPackageManager();
    int componentStatus = p.getComponentEnabledSetting(new ComponentName(this, LauncherActivity.class));
    return componentStatus != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}

From source file:com.onebus.view.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Log.i("MainActivity", "OnCreate");

    speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this,
            new ComponentName(this, VoiceRecognitionService.class));

    speechRecognizer.setRecognitionListener(this);

    mStationList = new ArrayList<HashMap<String, Object>>();

    try {/* w  w w  . j  a  va 2 s . com*/
        initMap();
        initWidget();

        // ?
        initOritationListener();

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:co.edu.uniajc.vtf.content.NavigationActivity.java

@Override
public void onPause() {
    super.onPause();
    ComponentName loComponent = new ComponentName(this, NetworkStatusReceiver.class);
    this.getPackageManager().setComponentEnabledSetting(loComponent,
            PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    try {/* w  ww.j av  a 2  s  .  com*/
        LocationServices.FusedLocationApi.removeLocationUpdates(coGoogleApiClient, this);
    } catch (Exception ex) {
    }
    this.hideProgressDialog();
}

From source file:com.darshancomputing.BatteryIndicatorPro.AlarmsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_help:
        ComponentName comp = new ComponentName(getActivity().getPackageName(),
                SettingsHelpActivity.class.getName());
        Intent intent = new Intent().setComponent(comp).putExtra(SettingsActivity.EXTRA_SCREEN,
                SettingsActivity.KEY_ALARMS_SETTINGS);
        startActivity(intent);/*  ww w .  ja  va  2 s.com*/

        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.android.transmart.services.PlaceCheckinService.java

/**
 * {@inheritDoc}/*from w  w w .ja  v  a  2 s .co m*/
 * Perform a checkin the specified venue. If the checkin fails, add it to the queue and
 * set an alarm to retry.
 * 
 * Query the checkin queue to see if there are pending checkins to be retried.
 */
@Override
protected void onHandleIntent(Intent intent) {
    // Retrieve the details for the checkin to perform.
    String reference = intent.getStringExtra(LocationConstants.EXTRA_KEY_REFERENCE);
    String id = intent.getStringExtra(LocationConstants.EXTRA_KEY_ID);
    long timeStamp = intent.getLongExtra(LocationConstants.EXTRA_KEY_TIME_STAMP, 0);

    // Check if we're running in the foreground, if not, check if
    // we have permission to do background updates.
    boolean backgroundAllowed = cm.getBackgroundDataSetting();
    boolean inBackground = sharedPreferences.getBoolean(LocationConstants.EXTRA_KEY_IN_BACKGROUND, true);

    if (reference != null && !backgroundAllowed && inBackground) {
        addToQueue(timeStamp, reference, id);
        return;
    }

    // Check to see if we are connected to a data network.
    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();

    // If we're not connected then disable the retry Alarm, enable the Connectivity Changed Receiver
    // and add the new checkin directly to the queue. The Connectivity Changed Receiver will listen
    // for when we connect to a network and start this service to retry the checkins.
    if (!isConnected) {
        // No connection so no point triggering an alarm to retry until we're connected.
        alarmManager.cancel(retryQueuedCheckinsPendingIntent);

        // Enable the Connectivity Changed Receiver to listen for connection to a network
        // so we can commit the pending checkins.
        PackageManager pm = getPackageManager();
        ComponentName connectivityReceiver = new ComponentName(this, ConnectivityChangedReceiver.class);
        pm.setComponentEnabledSetting(connectivityReceiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                PackageManager.DONT_KILL_APP);

        // Add this checkin to the queue.
        addToQueue(timeStamp, reference, id);
    } else {
        // Execute the checkin. If it fails, add it to the retry queue.
        if (reference != null) {
            if (!checkin(timeStamp, reference, id))
                addToQueue(timeStamp, reference, id);
        }

        // Retry the queued checkins.
        ArrayList<String> successfulCheckins = new ArrayList<String>();
        Cursor queuedCheckins = contentResolver.query(QueuedCheckinsContentProvider.CONTENT_URI, null, null,
                null, null);
        try {
            // Retry each checkin.
            while (queuedCheckins.moveToNext()) {
                long queuedTimeStamp = queuedCheckins
                        .getLong(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_TIME_STAMP));
                String queuedReference = queuedCheckins
                        .getString(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_REFERENCE));
                String queuedId = queuedCheckins
                        .getString(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_ID));
                if (queuedReference == null || checkin(queuedTimeStamp, queuedReference, queuedId))
                    successfulCheckins.add(queuedReference);
            }

            // Delete the queued checkins that were successful.
            if (successfulCheckins.size() > 0) {
                StringBuilder sb = new StringBuilder("(" + QueuedCheckinsContentProvider.KEY_REFERENCE + "='"
                        + successfulCheckins.get(0) + "'");
                for (int i = 1; i < successfulCheckins.size(); i++)
                    sb.append(" OR " + QueuedCheckinsContentProvider.KEY_REFERENCE + " = '"
                            + successfulCheckins.get(i) + "'");
                sb.append(")");
                int deleteCount = contentResolver.delete(QueuedCheckinsContentProvider.CONTENT_URI,
                        sb.toString(), null);
                Log.d(TAG, "Deleted: " + deleteCount);
            }

            // If there are still queued checkins then set a non-waking alarm to retry them.
            queuedCheckins.requery();
            if (queuedCheckins.getCount() > 0) {
                long triggerAtTime = System.currentTimeMillis() + LocationConstants.CHECKIN_RETRY_INTERVAL;
                alarmManager.set(AlarmManager.ELAPSED_REALTIME, triggerAtTime,
                        retryQueuedCheckinsPendingIntent);
            } else
                alarmManager.cancel(retryQueuedCheckinsPendingIntent);
        } finally {
            queuedCheckins.close();
        }
    }
}

From source file:cn.studyjams.s2.sj0119.NForget.AlarmReceiver.java

public void cancelAlarm(Context context, int ID) {
    mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    // Cancel Alarm using Reminder ID
    mPendingIntent = PendingIntent.getBroadcast(context, ID, new Intent(context, AlarmReceiver.class), 0);
    mAlarmManager.cancel(mPendingIntent);

    // Disable alarm
    ComponentName receiver = new ComponentName(context, BootReceiver.class);
    PackageManager pm = context.getPackageManager();
    pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
            PackageManager.DONT_KILL_APP);
}

From source file:com.android.usbtuner.DvbDeviceAccessor.java

@Nullable
@TargetApi(Build.VERSION_CODES.N)//from   w w w.ja v  a2s  .co m
public TvInputInfo buildTvInputInfo(Context context) {
    List<DvbDeviceInfoWrapper> deviceList = getDvbDeviceList();
    TvInputInfo.Builder builder = new TvInputInfo.Builder(context,
            new ComponentName(context, UsbTunerTvInputService.class));
    if (deviceList.size() > 0) {
        return builder.setCanRecord(CommonFeatures.DVR.isEnabled(context) && BuildCompat.isAtLeastN())
                .setTunerCount(deviceList.size()).build();
    } else {
        return null;
    }
}

From source file:org.wso2.emm.agent.services.operation.OperationManager.java

public OperationManager(Context context) {
    this.context = context;
    this.resources = context.getResources();
    this.devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
    this.cdmDeviceAdmin = new ComponentName(context, AgentDeviceAdminReceiver.class);
    this.appList = new ApplicationManager(context.getApplicationContext());
    this.resultBuilder = new ResultPayload();
    AGENT_PACKAGE_NAME = context.getPackageName();
    AUTHORIZED_PINNING_APPS = new String[] { AGENT_PACKAGE_NAME };
    applicationManager = new ApplicationManager(context);
    notificationService = NotificationService.getInstance(context.getApplicationContext());
    if (Constants.DEBUG_MODE_ENABLED) {
        Log.d(TAG, "New OperationManager created.");
    }/* ww w  . j a  va 2  s .  com*/
}