Example usage for android.content Intent setAction

List of usage examples for android.content Intent setAction

Introduction

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

Prototype

public @NonNull Intent setAction(@Nullable String action) 

Source Link

Document

Set the general action to be performed.

Usage

From source file:com.acrutiapps.browser.ui.components.CustomWebView.java

private Intent createIntent(String action, int actionId, int hitTestResult, String url) {
    Intent result = new Intent(getContext(), TintBrowserActivity.class);
    result.setAction(action);
    result.putExtra(Constants.EXTRA_ACTION_ID, actionId);
    result.putExtra(Constants.EXTRA_HIT_TEST_RESULT, hitTestResult);
    result.putExtra(Constants.EXTRA_URL, url);
    result.putExtra(Constants.EXTRA_INCOGNITO, isPrivateBrowsingEnabled());

    return result;
}

From source file:com.example.okano.simpleroutesearch.MapsActivity.java

/**
 * /*from  ww  w. ja v a2 s .  c  om*/
//     * @param from
//     * @param to
 */
//    private void searchRoot(LatLng from, LatLng to){
private void searchRoot() {
    String fromLat = "35.681382";
    String fromLng = "139.7660842";
    String toLat = "35.684752";
    String toLng = "139.707937";

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    //        intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
    //            intent.setClassName("com.example.okano.simpleroutesearch","com.example.okano.simpleroutesearch.MapsActivity");
    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
    //        String fromLat = Double.toString(from.latitude) ;
    //        String fromLng = Double.toString(from.longitude) ;
    //        String toLat = Double.toString(from.latitude) ;
    //        String toLng = Double.toString(from.longitude) ;
    intent.setData(Uri.parse(
            "http://maps.google.com/maps?saddr=" + fromLat + "," + fromLng + "&daddr=" + toLat + "," + toLng));
    startActivity(intent);

}

From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java

public void shareText(String txt) {
    Intent sendintent = new Intent(Intent.ACTION_SEND);
    sendintent.setAction(Intent.ACTION_SEND);
    sendintent.putExtra(Intent.EXTRA_TEXT, txt);
    sendintent.setType("text/plain");
    startActivity(Intent.createChooser(sendintent, "Share Url to..."));
}

From source file:io.coldstart.android.GCMIntentService.java

@Override
protected void onMessage(Context arg0, Intent intent) {
    String ns = Context.NOTIFICATION_SERVICE;
    mNM = (NotificationManager) arg0.getSystemService(ns);

    //Log.e("GCMIntentService","onMessageonMessageonMessageonMessage");

    //GCM Payload
    String alertCount = intent.getExtras().getString("alertCount");
    String maxSeverity = intent.getExtras().getString("alertSeverity");
    String alertTime = intent.getExtras().getString("alertTime");
    String alertType = intent.getExtras().getString("alertType");
    String payloadJSON = intent.getExtras().getString("payload");

    //Stuff from the payload
    String hostname = "---", TrapDetails = "---", IP = "", Date = "", Uptime = "",
            payloadDetails = "Unknown payload";

    //0 = a single alert
    if (alertType.equals(API.MSG_TRAP)) {
        if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("allowBundling", false)) {
            //Log.i("TRAP","Received a trap notification but I'm bundling");
            return;
        }/*from w  ww .  j  a v a  2s .  com*/

        try {
            JSONObject payload = new JSONObject(payloadJSON);

            //Log.i("payload",payload.toString(3));

            try {
                hostname = payload.getJSONObject("source").getString("hostname");
            } catch (Exception e) {
                hostname = "Unknown host";
            }

            try {
                //payloadDetails = payload.getJSONArray("trapdetails");
                payloadDetails = payload.getString("trapdetails");
            } catch (Exception e) {
                //e.printStackTrace();
                payloadDetails = "Unknown Trap payload";
            }

            try {
                IP = payload.getJSONObject("source").getString("ip");
            } catch (Exception e) {
                IP = "127.0.0.1";
            }

            try {
                Date = payload.getString("date");
            } catch (Exception e) {
                Date = "01/01/1970";
            }

            try {
                Uptime = payload.getString("uptime");
            } catch (Exception e) {
                Uptime = "";
            }
        } catch (Exception e) {
            //e.printStackTrace();
        }

        Trap trap = new Trap(hostname, IP);
        trap.date = Date;
        trap.uptime = Uptime;
        trap.trap = payloadDetails;

        if (Build.VERSION.SDK_INT >= 16) {
            SendInboxStyleNotification(alertCount, alertTime, hostname, trap.getPayloadAsString());
        } else {
            SendCombinedNotification(alertCount);
        }

        datasource = new TrapsDataSource(this);
        datasource.open();
        datasource.addRecentTrap(trap);
        datasource.close();

        //If the app is in the foreground we should instruct it to refresh
        Intent broadcast = new Intent();
        broadcast.setAction(API.BROADCAST_ACTION);
        sendBroadcast(broadcast);
    }
    //1 = an generic notification
    //TODO Create generic handler

    //2 = batch (a bit like rate limit but on user choice)
    else if (alertType.equals(API.MSG_BATCH)) {
        //Check we are ones after a bundled alert (many people share this GCM ID)
        if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("allowBundling", false)) {
            sendBatchNotification(intent.getExtras().getString("alertCount"));
        } else {
            //Log.i("BATCHING","Batching isn't enabled at the moment");
        }
    }
    //3 = Zenoss (for use with Rhybudd / coldstart HTTP API)
    else if (alertType.equals(API.MSG_ZENOSS)) {
        Intent broadcast = new Intent();
        broadcast.setAction(API.ZENOSS_BROADCAST_ACTION);
        sendBroadcast(broadcast);
    }
    //4 = rate limit hit
    else if (alertType.equals(API.MSG_RATELIMIT)) {
        sendRateLimitNotification(intent.getExtras().getString("ratelimit"));
    } else {
        //Do nothing
        //TODO Log an error / inform the user they need to update?
    }

}

From source file:cm.aptoide.pt.RemoteInSearch.java

private void installApk(String apk_pkg, int position) {
    pkginfo = mPm.getPackageArchiveInfo(apk_pkg, 0); //variavel global usada no retorno da instalacao
    Intent intent = new Intent();
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("file://" + apk_pkg), "application/vnd.android.package-archive");

    Message msg = new Message();
    msg.arg1 = 1;//from  w ww.j a v  a2  s  . c  o  m
    download_handler.sendMessage(msg);

    startActivityForResult(intent, position);
}

From source file:com.doplgangr.secrecy.settings.SettingsFragment.java

private void confirm_stealth(String password) {
    final View dialogView = View.inflate(context, R.layout.dialog_confirm_stealth, null);
    ((TextView) dialogView.findViewById(R.id.stealth_keycode)).append(password);
    new AlertDialog.Builder(context).setInverseBackgroundForced(true).setView(dialogView)
            .setMessage(R.string.Settings__try_once_before_hide)
            .setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context)
                            .edit();//from   ww w.  j  av  a 2 s .  c o m
                    editor.putBoolean(Config.SHOW_STEALTH_MODE_TUTORIAL, true);
                    editor.apply();
                    Intent dial = new Intent();
                    dial.setAction("android.intent.action.DIAL");
                    dial.setData(Uri.parse("tel:"));
                    dial.setFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(dial);
                    getActivity().finish();
                }
            }).show();
}

From source file:net.reichholf.dreamdroid.activities.TimerListActivity.java

/**
 * Open a <code>TimerEditActivity</code> for timer editing
 * /*from   w w w.j av  a 2  s.  c o m*/
 * @param timer
 *            The timer to be edited
 */
private void editTimer(ExtendedHashMap timer, boolean newTimer) {
    Intent intent = new Intent(this, TimerEditActivity.class);

    ExtendedHashMap data = new ExtendedHashMap();
    data.put("timer", timer);

    intent.putExtra(sData, data);

    if (!newTimer) {
        intent.setAction(Intent.ACTION_EDIT);
    } else {
        intent.setAction(DreamDroid.ACTION_NEW);
    }

    this.startActivityForResult(intent, CHANGE_TIMER_REQUEST);
}

From source file:com.example.healthplus.wifidirect.DeviceDetailFragment.java

public void sendFile() {

    String localIP = Utils.getLocalIPAddress();
    // Trick to find the ip in the file /proc/net/arp
    String client_mac_fixed = new String(device.deviceAddress).replace("3a", "38");
    Log.d(WiFiDirectActivity.TAG, "Client MAC fixed Richa: " + client_mac_fixed);
    String clientIP = Utils.getIPFromMac(client_mac_fixed);
    Log.d(WiFiDirectActivity.TAG, "Local IP Address Richa: " + localIP);
    Log.d(WiFiDirectActivity.TAG, "Client IP Address Richa: " + clientIP);
    // User has picked an image. Transfer it to group owner i.e peer using
    // FileTransferService.
    File root = android.os.Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
    String path = root.getAbsolutePath() + "/healthplus/" + "request.json";
    //Uri uri = new Uri.Builder().appendPath(path);

    //Log.d(WiFiDirectActivity.TAG, "URI richa: " + uri);
    TextView statusText = (TextView) mContentView.findViewById(R.id.status_text);
    statusText.setText("Sending: " + path);
    //Log.d(WiFiDirectActivity.TAG, "Intent----------- " + uri);
    Intent serviceIntent = new Intent(getActivity(), FileTransferService.class);
    Log.d(WiFiDirectActivity.TAG, "Reached here Richa before send");
    serviceIntent.setAction(FileTransferService.ACTION_SEND_FILE);
    //Log.d(WiFiDirectActivity.TAG, "Reached here Richa after send");
    //Log.d(WiFiDirectActivity.TAG, "Path : " + path);
    serviceIntent.putExtra(FileTransferService.EXTRAS_FILE_PATH, path);
    Log.d(WiFiDirectActivity.TAG, "Reached here Richa: put extra string to URI");
    Log.d(WiFiDirectActivity.TAG, "Reached here Richa after send");
    Log.d(WiFiDirectActivity.TAG, "Reached here Richa IP server =" + IP_SERVER);
    Log.d(WiFiDirectActivity.TAG, "Reached here Richa LOCAL IP =" + localIP);
    if (localIP.equals(IP_SERVER)) {
        Log.d(WiFiDirectActivity.TAG, "Reached here client IP1:" + clientIP);
        serviceIntent.putExtra(FileTransferService.EXTRAS_ADDRESS, clientIP);
        Log.d(WiFiDirectActivity.TAG, "Reached here client IP2:" + clientIP);
    } else {// w w  w  .j a v a  2 s  .c om
        Log.d(WiFiDirectActivity.TAG, "Reached here  IP server1:" + IP_SERVER);
        serviceIntent.putExtra(FileTransferService.EXTRAS_ADDRESS, IP_SERVER);
        Log.d(WiFiDirectActivity.TAG, "Reached here Extra address2:" + IP_SERVER);
    }

    serviceIntent.putExtra(FileTransferService.EXTRAS_PORT, PORT);
    Log.d(WiFiDirectActivity.TAG, "Reached here Richa service started");
    getActivity().startService(serviceIntent);
}

From source file:com.dnielfe.manager.AppManager.java

private void createshortcut() {
    Intent shortcutIntent = new Intent(AppManager.this, AppManager.class);
    shortcutIntent.setAction(Intent.ACTION_MAIN);

    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    Intent addIntent = new Intent();
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.appmanager));
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(AppManager.this, R.drawable.type_apk));
    addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    AppManager.this.sendBroadcast(addIntent);

    Toast.makeText(AppManager.this, getString(R.string.shortcutcreated), Toast.LENGTH_SHORT).show();
}

From source file:net.helff.wificonnector.WifiConnectivityService.java

protected void sendNotification(String msg) {
    Log.i(TAG, "send notification: " + msg);
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    Notification notification = new Notification(R.drawable.launchericon, msg, System.currentTimeMillis());

    Intent intent = new Intent(this, WifiConnectorActivity.class);
    intent.setAction("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.LAUNCHER");
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

    notification.setLatestEventInfo(this.getApplicationContext(), "WifiConnector", msg, pendingIntent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(1, notification);

}