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:gov.nasa.arc.geocam.geocam.CameraPreviewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Window and view properties
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.camera_preview);

    // Load bitmap from intent data and display in imageview
    mImageUri = getIntent().getData();//from ww w  .j  av  a2  s  .  co m
    try {
        mImageData = new JSONObject(getIntent().getExtras().getString("data"));
    } catch (JSONException e1) {
        Log.d(GeoCamMobile.DEBUG_ID, "Error unserializing JSON data from intent");
        mImageData = new JSONObject();
    }

    try {
        final BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inSampleSize = 4;
        InputStream in = getContentResolver().openInputStream(mImageUri);
        Bitmap bitmap = BitmapFactory.decodeStream(in, null, opts);

        //Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), mImageUri);
        ImageView imageView = (ImageView) findViewById(R.id.camera_preview_imageview);
        imageView.setAdjustViewBounds(true);
        imageView.setScaleType(ScaleType.CENTER_INSIDE);
        imageView.setImageBitmap(bitmap);
    } catch (FileNotFoundException e) {
        Log.d(GeoCamMobile.DEBUG_ID, "Error loading bitmap in CameraPreviewActivity");
    }

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    String defaultNotes = settings.getString(GeoCamMobile.SETTINGS_DEFAULT_NOTES_KEY, "");

    // Set default notes
    EditText notesText = (EditText) findViewById(R.id.camera_preview_edittext);
    notesText.setText(defaultNotes + " ");

    // Buttons
    mFireButton = (ImageButton) findViewById(R.id.camera_preview_fire_button);
    mFireButton.setImageDrawable(getResources().getDrawable(R.drawable.fire_icon_default));
    mFireButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_PICK);
            intent.setClass(CameraPreviewActivity.this, FireIconActivity.class);
            startActivityForResult(intent, PICK_ICON_REQUEST);
        }
    });

    final ImageButton deleteButton = (ImageButton) findViewById(R.id.camera_preview_delete_button);
    deleteButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            CameraPreviewActivity.this.showDialog(DIALOG_DELETE_PHOTO);
        }
    });

    final ImageButton saveButton = (ImageButton) findViewById(R.id.camera_preview_save_button);
    saveButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mImageNote = ((EditText) findViewById(R.id.camera_preview_edittext)).getText().toString();
            Log.d(GeoCamMobile.DEBUG_ID, "Setting image note to: " + mImageNote);
            saveWithAnnotation();
        }
    });

    mForeground = new ForegroundTracker(this);
}

From source file:com.digitalarx.android.files.FileOperationsHelper.java

public void unshareFileWithLink(OCFile file) {

    if (isSharedSupported()) {
        // Unshare the file
        Intent service = new Intent(mFileActivity, OperationsService.class);
        service.setAction(OperationsService.ACTION_UNSHARE);
        service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
        service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
        mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service);

        mFileActivity.showLoadingDialog();

    } else {//from  w ww . j  a v  a2 s. c  o m
        // Show a Message
        Toast t = Toast.makeText(mFileActivity,
                mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
        t.show();

    }
}

From source file:it.gulch.linuxday.android.services.AlarmIntentService.java

private PendingIntent getAlarmPendingIntent(long eventId) {
    Intent intent = new Intent(this, AlarmReceiver.class);
    intent.setAction(AlarmReceiver.ACTION_NOTIFY_EVENT);
    intent.setData(Uri.parse(String.valueOf(eventId)));

    return PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
}

From source file:com.openerp.services.ExpenseSyncService.java

/**
 * Perform sync.//from   ww w  .j a  v  a  2  s  . co  m
 *
 * @param context    the context
 * @param account    the account
 * @param extras     the extras
 * @param authority  the authority
 * @param provider   the provider
 * @param syncResult the sync result
 */
public void performSync(Context context, Account account, Bundle extras, String authority,
        ContentProviderClient provider, SyncResult syncResult) {

    Log.d(TAG, "ExpenseSyncService->performSync()");
    Intent intent = new Intent();
    Intent updateWidgetIntent = new Intent();
    updateWidgetIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    intent.setAction(SyncFinishReceiver.SYNC_FINISH);
    OEUser user = OpenERPAccountManager.getAccountDetail(context, account.name);
    try {
        ExpenseDBHelper expense_db = new ExpenseDBHelper(context);
        expense_db.setAccountUser(user);
        OEHelper oe = expense_db.getOEInstance();
        if (oe == null) {
            return;
        }
        int user_id = user.getUser_id();

        // Updating User Context for OE-JSON-RPC
        JSONObject newContext = new JSONObject();
        //newContext.put("default_model", "res.users");
        //newContext.put("default_res_id", user_id);

        OEArguments arguments = new OEArguments();
        // Param 1 : domain
        //OEDomain domain = new OEDomain();
        //arguments.add(domain);
        // Param 2 : context
        arguments.add(oe.updateContext(newContext));

        //???
        List<Integer> ids = expense_db.ids();
        if (oe.syncWithMethod("get_waiting_audit_expenses", arguments, true)) {
            int affected_rows = oe.getAffectedRows();
            Log.d(TAG, "ExpenseSyncService[arguments]:" + arguments.toString());
            Log.d(TAG, "ExpenseSyncService->affected_rows:" + affected_rows);
            List<Integer> affected_ids = oe.getAffectedIds();
            boolean notification = true;
            ActivityManager am = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
            List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
            ComponentName componentInfo = taskInfo.get(0).topActivity;
            if (componentInfo.getPackageName().equalsIgnoreCase("com.openerp")) {
                notification = false;
            }
            if (notification && affected_rows > 0) {
                OENotificationHelper mNotification = new OENotificationHelper();
                Intent mainActiivty = new Intent(context, MainActivity.class);
                mainActiivty.setAction("EXPENSES");
                mNotification.setResultIntent(mainActiivty, context);

                String notify_title = context.getResources().getString(R.string.expenses_sync_notify_title);
                notify_title = String.format(notify_title, affected_rows);

                String notify_body = context.getResources().getString(R.string.expenses_sync_notify_body);
                notify_body = String.format(notify_body, affected_rows);

                mNotification.showNotification(context, notify_title, notify_body, authority,
                        R.drawable.ic_oe_notification);
            }
            intent.putIntegerArrayListExtra("new_ids", (ArrayList<Integer>) affected_ids);
        }
        //?expense?
        List<Integer> updated_ids = updateOldExpenses(expense_db, oe, user, ids);

    } catch (Exception e) {
        e.printStackTrace();
    }
    if (user.getAndroidName().equals(account.name)) {
        context.sendBroadcast(intent);
        //context.sendBroadcast(updateWidgetIntent);
    }
}

From source file:io.indy.drone.service.ScheduledService.java

@Override
protected void onHandleIntent(Intent intent) {
    ifd("onHandleIntent");

    boolean isPullToRefresh = intent.getBooleanExtra(StrikeListActivity.ResponseReceiver.IS_PTR, false);
    if (isPullToRefresh) {
        ifd("invoked service via pull to refresh");
    }// w w w .j  av a 2s  .c om

    mDatabase = new SQLDatabase(this);

    // called by a repeating alarm so update sharedpreferences with the current time
    updateAlarmTime();

    try {
        int serverCount = fetchStrikesCount();
        int localCount = mDatabase.getNumStrikes();

        if (localCount == 0) {
            ifd("localCount == 0");
            return;
        }

        if (localCount < serverCount) {
            // there's new strike data in the server
            ifd("new strike data found on server");
            JSONArray jsonStrikes = fetchNewStrikes(localCount);
            if (jsonStrikes == null) {
                ifd("fetching new strike data returned null");
                return;
            }

            ifd("adding strike data to local db");
            addStrikes(jsonStrikes);

            // event to inform list that new strike data is in the db
            EventBus.getDefault().post(new UpdatedDatabaseEvent());

            // create a notification
            if (!isPullToRefresh) {
                createNotification();
            }

        } else {
            ifd("serverCount (" + serverCount + ") not greater than localCount (" + localCount + ")");
        }

        if (isPullToRefresh) {
            Intent broadcastIntent = new Intent();
            broadcastIntent.setAction(StrikeListActivity.ResponseReceiver.ACTION_RESP);
            broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
            int diff = serverCount - localCount;
            broadcastIntent.putExtra(StrikeListActivity.ResponseReceiver.STRIKE_DIFF, diff);
            sendBroadcast(broadcastIntent);
        }

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

From source file:com.nextgis.maplibui.mapui.LayerFactoryUI.java

@Override
public void createNewLocalTMSLayer(final Context context, final LayerGroup groupLayer, final Uri uri) {
    String ext = "zip";
    String layerName = FileUtil.getFileNameByUri(context, uri, context.getString(R.string.new_layer));
    final int lastPeriodPos = layerName.lastIndexOf('.');
    if (lastPeriodPos > 0) {
        ext = layerName.substring(lastPeriodPos).toLowerCase();
        layerName = layerName.substring(0, lastPeriodPos);
    }/*  w  w  w.  j  a v a  2 s  . com*/
    if (context instanceof NGActivity) {
        NGActivity fragmentActivity = (NGActivity) context;

        if (ext.equals(".ngrc")) {
            Intent intent = new Intent(context, LayerFillService.class);
            intent.setAction(LayerFillService.ACTION_ADD_TASK);
            intent.putExtra(LayerFillService.KEY_URI, uri);
            intent.putExtra(LayerFillService.KEY_INPUT_TYPE, LayerFillService.TMS_LAYER);
            intent.putExtra(LayerFillService.KEY_LAYER_GROUP_ID, groupLayer.getId());

            LayerFillProgressDialogFragment.startFill(intent);
            return;
        }

        AtomicReference<Uri> temp = new AtomicReference<>(uri);
        if (MapUtil.isZippedGeoJSON(context, temp)) {
            createNewVectorLayer(context, groupLayer, temp.get());
            return;
        }

        CreateLocalLayerDialog newFragment = new CreateLocalLayerDialog();
        newFragment.setLayerGroup(groupLayer).setLayerType(LayerFillService.TMS_LAYER).setUri(uri)
                .setLayerName(layerName).setTitle(context.getString(R.string.create_tms_layer))
                .setTheme(fragmentActivity.getThemeId())
                .show(fragmentActivity.getSupportFragmentManager(), "create_tms_layer");
    }
}

From source file:me.kartikarora.transfersh.activities.TransferActivity.java

public void updateWidgets() {
    Intent intent = new Intent(TransferActivity.this, FilesAppWidgetProvider.class);
    intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    AppWidgetManager widgetManager = AppWidgetManager.getInstance(getApplicationContext());
    int[] ids = widgetManager
            .getAppWidgetIds(new ComponentName(getApplicationContext(), FilesAppWidgetProvider.class));
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
    sendBroadcast(intent);// w w  w.j a  v  a2 s.  c om
}

From source file:com.openerp.services.VoucherSyncService.java

/**
 * Perform sync.//w  w  w  .j  av a 2s.  c  om
 *
 * @param context    the context
 * @param account    the account
 * @param extras     the extras
 * @param authority  the authority
 * @param provider   the provider
 * @param syncResult the sync result
 */
public void performSync(Context context, Account account, Bundle extras, String authority,
        ContentProviderClient provider, SyncResult syncResult) {

    Log.d(TAG, "VoucherSyncService->performSync()");
    Intent intent = new Intent();
    Intent updateWidgetIntent = new Intent();
    updateWidgetIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    intent.setAction(SyncFinishReceiver.SYNC_FINISH);
    OEUser user = OpenERPAccountManager.getAccountDetail(context, account.name);
    try {
        VoucherDB voucherDb = new VoucherDB(context);
        voucherDb.setAccountUser(user);
        OEHelper oe = voucherDb.getOEInstance();
        if (oe == null) {
            return;
        }
        int user_id = user.getUser_id();

        // Updating User Context for OE-JSON-RPC
        JSONObject newContext = new JSONObject();
        //newContext.put("default_model", "res.users");
        //newContext.put("default_res_id", user_id);

        OEArguments arguments = new OEArguments();
        // Param 1 : domain
        OEDomain domain = new OEDomain();
        //type = payment
        arguments.add(domain);
        // Param 2 : context
        arguments.add(oe.updateContext(newContext));

        //???
        List<Integer> ids = voucherDb.ids();
        if (oe.syncWithMethod("get_waiting_audit_vouchers", arguments, true)) {
            int affected_rows = oe.getAffectedRows();
            Log.d(TAG, "VoucherSyncService[arguments]:" + arguments.toString());
            Log.d(TAG, "VoucherSyncService->affected_rows:" + affected_rows);
            List<Integer> affected_ids = oe.getAffectedIds();
            boolean notification = true;
            ActivityManager am = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
            List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
            ComponentName componentInfo = taskInfo.get(0).topActivity;
            if (componentInfo.getPackageName().equalsIgnoreCase("com.openerp")) {
                notification = false;
            }
            if (notification && affected_rows > 0) {
                OENotificationHelper mNotification = new OENotificationHelper();
                Intent mainActiivty = new Intent(context, MainActivity.class);
                mainActiivty.setAction("VOUCHERS");
                mNotification.setResultIntent(mainActiivty, context);

                String notify_title = context.getResources().getString(R.string.vouchers_sync_notify_title);
                notify_title = String.format(notify_title, affected_rows);

                String notify_body = context.getResources().getString(R.string.vouchers_sync_notify_body);
                notify_body = String.format(notify_body, affected_rows);

                mNotification.showNotification(context, notify_title, notify_body, authority,
                        R.drawable.ic_oe_notification);
            }
            intent.putIntegerArrayListExtra("new_ids", (ArrayList<Integer>) affected_ids);
        }
        //?expense?
        List<Integer> updated_ids = updateOldVouchers(voucherDb, oe, user, ids);

    } catch (Exception e) {
        e.printStackTrace();
    }
    if (user.getAndroidName().equals(account.name)) {
        context.sendBroadcast(intent);
        //context.sendBroadcast(updateWidgetIntent);
    }
}

From source file:com.otaupdater.utils.KernelInfo.java

public void showUpdateNotif(Context ctx) {
    Intent mainInent = new Intent(ctx, TabDisplay.class);
    mainInent.setAction(TabDisplay.KERNEL_NOTIF_ACTION);
    this.addToIntent(mainInent);
    PendingIntent mainPIntent = PendingIntent.getActivity(ctx, 0, mainInent, PendingIntent.FLAG_CANCEL_CURRENT);

    Intent dlInent = new Intent(ctx, DownloadReceiver.class);
    dlInent.setAction(DownloadReceiver.DL_KERNEL_ACTION);
    this.addToIntent(dlInent);
    PendingIntent dlPIntent = PendingIntent.getBroadcast(ctx, 0, dlInent, PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
    builder.setContentIntent(mainPIntent);
    builder.setContentTitle(ctx.getString(R.string.notif_source));
    builder.setContentText(ctx.getString(R.string.notif_text_kernel));
    builder.setTicker(ctx.getString(R.string.notif_text_kernel));
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(R.drawable.updates);
    builder.setStyle(new NotificationCompat.BigTextStyle().bigText(changelog));
    builder.setPriority(NotificationCompat.PRIORITY_LOW);
    builder.addAction(R.drawable.ic_download_default, ctx.getString(R.string.notif_download), dlPIntent);

    NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(Config.KERNEL_NOTIF_ID, builder.build());
}

From source file:com.otaupdater.utils.RomInfo.java

public void showUpdateNotif(Context ctx) {
    Intent mainInent = new Intent(ctx, TabDisplay.class);
    mainInent.setAction(TabDisplay.ROM_NOTIF_ACTION);
    this.addToIntent(mainInent);
    PendingIntent mainPIntent = PendingIntent.getActivity(ctx, 0, mainInent, PendingIntent.FLAG_CANCEL_CURRENT);

    Intent dlInent = new Intent(ctx, DownloadReceiver.class);
    dlInent.setAction(DownloadReceiver.DL_ROM_ACTION);
    this.addToIntent(dlInent);
    PendingIntent dlPIntent = PendingIntent.getBroadcast(ctx, 0, dlInent, PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
    builder.setContentIntent(mainPIntent);
    builder.setContentTitle(ctx.getString(R.string.notif_source));
    builder.setContentText(ctx.getString(R.string.notif_text_rom));
    builder.setTicker(ctx.getString(R.string.notif_text_rom));
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(R.drawable.updates);
    builder.setStyle(new NotificationCompat.BigTextStyle().bigText(changelog));
    builder.setPriority(NotificationCompat.PRIORITY_LOW);
    builder.addAction(R.drawable.ic_download_default, ctx.getString(R.string.notif_download), dlPIntent);

    NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(Config.ROM_NOTIF_ID, builder.build());
}