Example usage for android.content Intent ACTION_DELETE

List of usage examples for android.content Intent ACTION_DELETE

Introduction

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

Prototype

String ACTION_DELETE

To view the source code for android.content Intent ACTION_DELETE.

Click Source Link

Document

Activity Action: Delete the given data from its container.

Usage

From source file:Main.java

public static void uninstallApp(Context context, String packageName) {
    Uri uri = Uri.parse("package:" + packageName);
    Intent intent = new Intent(Intent.ACTION_DELETE, uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//w  w w  . j a  v a  2 s. c o  m
}

From source file:Main.java

public static void uninstall(Context context, String packageName) {
    Uri uri = Uri.fromParts("package", packageName, null);
    Intent it = new Intent(Intent.ACTION_DELETE, uri);
    context.startActivity(it);/*from   w  w  w.  j a va  2  s  .c  o m*/
}

From source file:Main.java

public static void uninstallApp(Context context, String packageName) {
    // Create new intent to launch Uninstaller activity
    Uri packageURI = Uri.parse("package:" + packageName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
    context.startActivity(uninstallIntent);
}

From source file:org.adaway.ui.ScanAdwareListFragment.java

@Override
public void onListItemClick(ListView listView, View view, int position, long id) {
    Map<String, String> item = (Map<String, String>) listView.getItemAtPosition(position);

    String packageName = item.get("package_name");

    // offer uninstall
    Intent i = new Intent(Intent.ACTION_DELETE);
    i.setData(Uri.parse("package:" + packageName));
    startActivity(i);//w w w . j a  v  a2 s  . c o m
}

From source file:com.noshufou.android.su.InstallReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    PackageManager pm = context.getPackageManager();
    String packageName = intent.getDataString().split(":")[1];
    PackageInfo packageInfo = null;/*w ww  .  j  av a 2 s.  c om*/

    try {
        packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
    } catch (NameNotFoundException e) {
        // This won't happen, but if it does, we don't continue
        Log.e(TAG, "PackageManager divided by zero...", e);
        return;
    }

    if (Util.isPackageMalicious(context, packageInfo) != 0) {
        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        Intent notificationIntent = new Intent(Intent.ACTION_DELETE, intent.getData());
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
        Notification notification = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.stat_su)
                .setTicker(context.getText(R.string.malicious_app_notification_ticker))
                .setWhen(System.currentTimeMillis()).setContentTitle(context.getText(R.string.app_name))
                .setContentText(context.getString(R.string.malicious_app_notification_text,
                        pm.getApplicationLabel(packageInfo.applicationInfo)))
                .setContentIntent(contentIntent).setAutoCancel(true).getNotification();
        nm.notify(0, notification);
    }
}

From source file:org.klnusbaum.udj.network.EventCommService.java

@Override
public void onHandleIntent(Intent intent) {
    Log.d(TAG, "In Event Comm Service");
    AccountManager am = AccountManager.get(this);
    final Account account = (Account) intent.getParcelableExtra(Constants.ACCOUNT_EXTRA);
    if (intent.getAction().equals(Intent.ACTION_INSERT)) {
        enterEvent(intent, am, account, true);
    } else if (intent.getAction().equals(Intent.ACTION_DELETE)) {
        //TODO handle if userId is null shouldn't ever be, but hey...
        leaveEvent(am, account, true);//from  w  w w  .ja v  a 2  s  . c  o  m
    } else {
        Log.d(TAG, "ACTION wasn't delete or insert, it was " + intent.getAction());
    }
}

From source file:com.github.jthuraisamy.yellowusage.ui.InvalidNetworkDialog.java

@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final MainActivity ctx = (MainActivity) getActivity();
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctx);

    // Set title and message.
    alertDialog.setTitle(R.string.invalid_network_title);
    alertDialog.setMessage(String.format(getString(R.string.invalid_network_message), networkOperatorName));

    // Set OnClickListener for negative button.
    alertDialog.setNegativeButton(R.string.action_exit, new DialogInterface.OnClickListener() {
        @Override//from  w  w  w  .  j a  va2  s.co  m
        public void onClick(DialogInterface dialogInterface, int i) {
            ctx.finish();
        }
    });

    // Set OnClickListener for positive button.
    alertDialog.setPositiveButton(R.string.action_uninstall, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            Uri packageURI = Uri.parse("package:com.github.jthuraisamy.yellowusage");
            Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
            startActivity(uninstallIntent);

            // Show the dialog again in case the user clicks cancel in the uninstall dialog.
            InvalidNetworkDialog invalidNetworkDialog = InvalidNetworkDialog.create(networkOperatorName);
            invalidNetworkDialog.show(getFragmentManager(), InvalidNetworkDialog.TAG);
        }
    });

    return alertDialog.create();
}

From source file:devicroft.burnboy.Activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(LOG_TAG, "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initialiseAd();/*from  www  . j a v  a 2  s. c  o m*/
    setupFAB();

    IntentFilter filter = new IntentFilter("devicroft.BurnBoy.CANCEL_NOTIFY");
    this.registerReceiver(new NotificationCancelReceiver(), filter);
    if (getIntent().getAction() == Intent.ACTION_DELETE) {
        Intent intent = new Intent();
        intent.setAction("devicroft.BurnBoy.CANCEL_NOTIFY");
        intent.putExtra("id", NotificationCancelReceiver.NOTIFICATION_ID);
        sendBroadcast(intent);
    }

    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (LogService.getName().equals(service.service.getClassName())) {
            Log.d(LOG_TAG, " REBIND on SERVICE");
            Toast.makeText(this, "Still logging movement", Toast.LENGTH_SHORT);
            this.bindService(new Intent(this, LogService.class), serviceConnection, Context.BIND_AUTO_CREATE);
        }
    }

    TextView distance = (TextView) findViewById(R.id.distanceFocus);
}

From source file:org.klnusbaum.udj.network.PlaylistSyncService.java

@Override
public void onHandleIntent(Intent intent) {
    final Account account = (Account) intent.getParcelableExtra(Constants.ACCOUNT_EXTRA);
    String playerId = AccountManager.get(this).getUserData(account, Constants.LAST_PLAYER_ID_DATA);
    //TODO handle error if playerId is bad
    if (intent.getAction().equals(Intent.ACTION_INSERT)) {
        if (intent.getData().equals(Constants.PLAYLIST_URI)) {
            String libId = intent.getStringExtra(Constants.LIB_ID_EXTRA);
            addSongToPlaylist(account, playerId, libId, true, intent);
        } else if (intent.getData().equals(Constants.VOTES_URI)) {
            //TODO handle if lib id is bad
            String libId = intent.getStringExtra(Constants.LIB_ID_EXTRA);
            //TODO handle if votetype is bad
            int voteWeight = intent.getIntExtra(Constants.VOTE_WEIGHT_EXTRA, 0);
            voteOnSong(account, playerId, libId, voteWeight, true);
        }//from  w ww.  j av a2s.c o m
        //updateActivePlaylist(account, playerId, true); 
    }
    /*else if(intent.getAction().equals(Intent.ACTION_VIEW)){
      updateActivePlaylist(account, playerId, true); 
    }*/
    else if (intent.getAction().equals(Intent.ACTION_DELETE)) {
        Log.d(TAG, "Handling delete");
        if (intent.getData().equals(Constants.PLAYLIST_URI)) {
            Log.d(TAG, "In plalist syncservice, about to insert song into remove requests");
            //TODO handle if Playlist id is bad.
            String libId = intent.getStringExtra(Constants.LIB_ID_EXTRA);
            removeSongFromPlaylist(account, playerId, libId, true, intent);
        }
        //updateActivePlaylist(account, playerId, true);
    } else if (intent.getAction().equals(Constants.ACTION_SET_CURRENT_SONG)) {
        Log.d(TAG, "Handling setting current song");
        String libId = intent.getStringExtra(Constants.LIB_ID_EXTRA);
        setCurrentSong(account, playerId, libId, true, intent);
        //updateActivePlaylist(account, playerId, true);
    } else if (intent.getAction().equals(Constants.ACTION_SET_PLAYBACK)) {
        setPlaybackState(intent, account, playerId, true);
        //updateActivePlaylist(account, playerId, true);
    } else if (intent.getAction().equals(Constants.ACTION_SET_VOLUME)) {
        setPlayerVolume(intent, account, playerId, true);
        //updateActivePlaylist(account, playerId, true);
    }
}

From source file:com.audacity.booster.fragments.DetectorFragment.java

@Override
public void onListItemClick(ListView listView, View view, int position, long id) {
    // Uninstall the app
    PackageInfo pkg = mAdSources.adSources.get(position).packageInfo;
    Intent i = new Intent(Intent.ACTION_DELETE);
    i.setData(Uri.parse("package:" + pkg.packageName));
    startActivity(i);/*from www  . j  av  a  2  s.  c  o  m*/
}