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.mobile.godot.activity.LauncherActivity.java

private void goToMain(UserBean user) {
    Intent intentLoggedUser = new Intent(this, MainActivity.class);
    intentLoggedUser.setAction(GodotIntent.Session.LOGIN);
    intentLoggedUser.putExtra(GodotIntentExtra.EXTRA_USER, user);
    this.startActivity(intentLoggedUser);

}

From source file:org.wso2.iot.agent.services.MessageProcessor.java

@SuppressWarnings("unused")
@Override/* w ww .  j  a  v  a  2s .  co m*/
public void onReceiveAPIResult(Map<String, String> result, int requestCode) {
    String responseStatus;
    String response;
    if (requestCode == Constants.NOTIFICATION_REQUEST_CODE) {
        Preference.putLong(context, Constants.PreferenceFlag.LAST_SERVER_CALL,
                CommonUtils.currentDate().getTime());
        Intent intent = new Intent();
        intent.setAction(Constants.SYNC_BROADCAST_ACTION);
        context.sendBroadcast(intent);

        if (isWipeTriggered) {
            if (Constants.SYSTEM_APP_ENABLED) {
                CommonUtils.callSystemApp(context, Constants.Operation.WIPE_DATA, null, null);
            } else {
                Log.i(TAG, "Not the device owner.");
            }
        }

        if (isEnterpriseWipeTriggered) {
            CommonUtils.disableAdmin(context);

            Intent intentEnterpriseWipe = new Intent(context, ServerConfigsActivity.class);
            intentEnterpriseWipe.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intentEnterpriseWipe.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intentEnterpriseWipe);
            if (Constants.DEBUG_MODE_ENABLED) {
                Log.d(TAG, "Started enterprise wipe");
            }
        }

        if (isRebootTriggered) {
            CommonUtils.callSystemApp(context, Constants.Operation.REBOOT, null, null);
        }

        if (isUpgradeTriggered) {
            String schedule = Preference.getString(context,
                    context.getResources().getString(R.string.pref_key_schedule));
            CommonUtils.callSystemApp(context, Constants.Operation.UPGRADE_FIRMWARE, schedule, null);
        }

        if (isShellCommandTriggered && shellCommand != null) {
            CommonUtils.callSystemApp(context, Constants.Operation.EXECUTE_SHELL_COMMAND, shellCommand, null);
        }

        if (result != null) {
            responseStatus = result.get(Constants.STATUS_KEY);
            response = result.get(Constants.RESPONSE);
            if (Constants.Status.SUCCESSFUL.equals(responseStatus)
                    || Constants.Status.CREATED.equals(responseStatus)) {
                if (response != null && !response.isEmpty()) {
                    if (Constants.DEBUG_MODE_ENABLED) {
                        Log.d(TAG, "Pending Operations List: " + response);
                    }
                    if (Constants.DEFAULT_OWNERSHIP.equals(Constants.OWNERSHIP_COSU)) {
                        if (!Preference.getBoolean(context, Constants.PreferenceFlag.DEVICE_INITIALIZED)) {
                            Preference.putBoolean(context, Constants.PreferenceFlag.DEVICE_INITIALIZED, true);
                        }
                    }
                    performOperation(response);
                }
            } else if (Constants.Status.AUTHENTICATION_FAILED.equals(responseStatus)
                    && org.wso2.iot.agent.proxy.utils.Constants.REFRESH_TOKEN_EXPIRED.equals(response)) {
                Log.d(TAG, "Requesting credentials to obtain new token pair.");
                LocalNotification.stopPolling(context);
                Preference.putBoolean(context, Constants.TOKEN_EXPIRED, true);
                CommonUtils.displayNotification(context, R.drawable.ic_error_outline_white_24dp,
                        context.getResources().getString(R.string.title_need_to_sign_in),
                        context.getResources().getString(R.string.msg_need_to_sign_in),
                        AuthenticationActivity.class, Constants.TOKEN_EXPIRED,
                        Constants.SIGN_IN_NOTIFICATION_ID);
            }
        }
    }
}

From source file:com.example.ridemepassenger.WaitHeComeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_wait_he_come);

    Bundle extras = getIntent().getExtras();
    d_name = extras.getString(DRIVERNAME);
    d_phone = extras.getString(DRIVERPHONE);
    d_avatar = extras.getString(DRIVEAVATAR);
    d_license = extras.getString(DRIVERLICENSE);
    d_model = extras.getString(DRIVERMODEL);
    d_stars = extras.getString(DRIVERSTARS);
    d_dealnum = extras.getString(DRIVERDEALNUM);

    name_txt = (TextView) findViewById(R.id.wait_he_come_name);
    license_txt = (TextView) findViewById(R.id.wait_he_come_license);
    model_txt = (TextView) findViewById(R.id.wait_he_come_model);
    dealnum_txt = (TextView) findViewById(R.id.wait_he_come_tradenum);
    avatar = (ImageView) findViewById(R.id.show_order_avatar);
    dial = (ImageView) findViewById(R.id.wait_he_come_dial);
    commit_btn = (Button) findViewById(R.id.wait_he_come_bt);

    name_txt.setText(d_name);//w  w  w  . java2 s .co  m
    license_txt.setText(d_license);
    model_txt.setText(d_license);
    dealnum_txt.setText(d_dealnum);

    new GetImageCache(avatar, GetImageCache.PIC_NAME).execute(d_avatar);

    commit_btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            new sendto_sever().execute();
        }
    });

    dial.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent();
            intent.setAction("android.intent.action.CALL");
            intent.setData(Uri.parse("tel:" + d_phone));//mobile
            startActivity(intent);
        }
    });

    mMapView = (MapView) findViewById(R.id.bmapView);
    mMapView.showScaleControl(false);
    mMapView.showZoomControls(false);
    mBaiduMap = mMapView.getMap();
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.zoomTo(19f));
    //  
    mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
    mLocationClient = new LocationClient(getApplicationContext()); //LocationClient
    initLocation();
    mLocationClient.registerLocationListener(myListener); //
    mLocationClient.start();
}

From source file:edu.mit.media.funf.configured.ConfiguredPipeline.java

private void scheduleAlarm(String action, long delayInSeconds) {
    Intent i = new Intent(this, getClass());
    i.setAction(action);
    boolean noAlarmExists = (PendingIntent.getService(this, 0, i, PendingIntent.FLAG_NO_CREATE) == null);
    if (noAlarmExists) {
        PendingIntent pi = PendingIntent.getService(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
        long delayInMilliseconds = Utils.secondsToMillis(delayInSeconds);
        long startTimeInMilliseconds = System.currentTimeMillis() + delayInMilliseconds;
        Log.i(TAG, "Scheduling alarm for '" + action + "' at " + Utils.millisToSeconds(startTimeInMilliseconds)
                + " and every " + delayInSeconds + " seconds");
        // Inexact repeating doesn't work unlesss interval is 15, 30 min, or 1, 6, or 24 hours
        alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, startTimeInMilliseconds, delayInMilliseconds,
                pi);/*  w  w w  . j  a va 2  s  .  c  om*/
    }
}

From source file:com.krayzk9s.imgurholo.ui.AccountFragment.java

private void selectItem(int position) {
    Intent intent;
    switch (position) {
    case 0://from  ww  w  . j ava  2  s . c o  m
        intent = new Intent();
        intent.putExtra("username", "me");
        intent.setAction(ImgurHoloActivity.ALBUMS_INTENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        startActivity(intent);
        break;
    case 1:
        intent = new Intent();
        intent.putExtra("imageCall", "3/account/" + username + "/images");
        intent.setAction(ImgurHoloActivity.IMAGES_INTENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        startActivity(intent);
        break;
    case 2:
        intent = new Intent();
        intent.putExtra("imageCall", "3/account/" + username + "/likes");
        intent.setAction(ImgurHoloActivity.IMAGES_INTENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        startActivity(intent);
        break;
    case 3:
        intent = new Intent();
        intent.putExtra("username", username);
        intent.setAction(ImgurHoloActivity.COMMENTS_INTENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        startActivity(intent);
        break;
    default:
        break;
    }
}

From source file:edu.mit.media.funf.configured.ConfiguredPipeline.java

public void archiveData() {
    Intent i = new Intent(this, getDatabaseServiceClass());
    i.setAction(DatabaseService.ACTION_ARCHIVE);
    i.putExtra(DatabaseService.DATABASE_NAME_KEY, getPipelineName());
    startService(i);/*from  ww w. j av  a  2 s  .  c  o  m*/
}

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

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    // User has picked an image. Transfer it to group owner i.e peer using
    // FileTransferService.
    Uri uri = data.getData();/*from w  w  w  . j a  v  a  2 s . c  om*/
    TextView statusText = (TextView) mContentView.findViewById(R.id.status_text);
    statusText.setText("Sending: " + uri);
    Log.d(WiFiDirectActivity.TAG, "Intent----------- " + uri);
    Intent serviceIntent = new Intent(getActivity(), FileTransferService.class);
    serviceIntent.setAction(FileTransferService.ACTION_SEND_FILE);
    serviceIntent.putExtra(FileTransferService.EXTRAS_FILE_PATH, uri.toString());
    serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_ADDRESS,
            info.groupOwnerAddress.getHostAddress());
    serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_PORT, 8988);
    getActivity().startService(serviceIntent);

}

From source file:edu.mit.media.funf.configured.ConfiguredPipeline.java

protected void onConfigChange(String json) {
    // Record configuration change to database
    Intent i = new Intent(this, getDatabaseServiceClass());
    i.setAction(DatabaseService.ACTION_RECORD);
    i.putExtra(DatabaseService.DATABASE_NAME_KEY, getPipelineName());
    i.putExtra(NameValueDatabaseService.TIMESTAMP_KEY, System.currentTimeMillis());
    i.putExtra(NameValueDatabaseService.NAME_KEY, getClass().getName());
    i.putExtra(NameValueDatabaseService.VALUE_KEY, json);
    startService(i);/*  w  w w . ja  va2s . c o m*/
}

From source file:com.parse.ParsePushBroadcastReceiver.java

/**
 * Called when the push notification is received. By default, a broadcast intent will be sent if
 * an "action" is present in the data and a notification will be show if "alert" and "title" are
 * present in the data./*from   ww w  . j a  v a2  s .c om*/
 *
 * @param context
 *      The {@code Context} in which the receiver is running.
 * @param intent
 *      An {@code Intent} containing the channel and data of the current push notification.
 */
protected void onPushReceive(Context context, Intent intent) {
    String pushDataStr = intent.getStringExtra(KEY_PUSH_DATA);
    if (pushDataStr == null) {
        PLog.e(TAG, "Can not get push data from intent.");
        return;
    }
    PLog.v(TAG, "Received push data: " + pushDataStr);

    JSONObject pushData = null;
    try {
        pushData = new JSONObject(pushDataStr);
    } catch (JSONException e) {
        PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e);
    }

    // If the push data includes an action string, that broadcast intent is fired.
    String action = null;
    if (pushData != null) {
        action = pushData.optString("action", null);
    }
    if (action != null) {
        Bundle extras = intent.getExtras();
        Intent broadcastIntent = new Intent();
        broadcastIntent.putExtras(extras);
        broadcastIntent.setAction(action);
        broadcastIntent.setPackage(context.getPackageName());
        context.sendBroadcast(broadcastIntent);
    }

    Notification notification = getNotification(context, intent);

    if (notification != null) {
        ParseNotificationManager.getInstance().showNotification(context, notification);
    }
}

From source file:edu.mit.media.funf.configured.ConfiguredPipeline.java

public void onDataReceived(Bundle data) {
    String dataJson = getBundleSerializer().serialize(data);
    String probeName = data.getString(Probe.PROBE);
    long timestamp = data.getLong(Probe.TIMESTAMP, 0L);
    Bundle b = new Bundle();
    b.putString(NameValueDatabaseService.DATABASE_NAME_KEY, getPipelineName());
    b.putLong(NameValueDatabaseService.TIMESTAMP_KEY, timestamp);
    b.putString(NameValueDatabaseService.NAME_KEY, probeName);
    b.putString(NameValueDatabaseService.VALUE_KEY, dataJson);
    Intent i = new Intent(this, getDatabaseServiceClass());
    i.setAction(DatabaseService.ACTION_RECORD);
    i.putExtras(b);/*from w w  w  . j  ava 2s  .co  m*/
    startService(i);
}