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:be.benvd.mvforandroid.SettingsActivity.java

private void startService() {
    Intent start = new Intent(this, MVDataService.class);
    start.setAction(MVDataService.SCHEDULE_SERVICE);
    WakefulIntentService.sendWakefulWork(this, start);
}

From source file:com.daon.identityx.samplefidoapp.SplashActivity.java

/***
 * Attempt to get the list of UAF Clients on the device and
 * add these to the static list./*from   w ww  . jav a  2s .co  m*/
 *
 */
protected void loadUafClientList() {

    List<ResolveInfo> clientList;
    final Intent intent = new Intent();
    intent.setAction(AndroidClientIntentParameters.intentAction);
    intent.setType(AndroidClientIntentParameters.intentType);

    PackageManager manager = this.getPackageManager();
    clientList = manager.queryIntentActivities(intent, 0);
    UafClientLogUtils.logUafClientActivities(clientList);
    getUafClientList().addAll(clientList);
}

From source file:com.horizondigital.delta.UpdateService.java

private static void start(Context context, String action) {
    Intent i = new Intent(context, UpdateService.class);
    i.setAction(action);
    context.startService(i);//from   w ww  .j  ava2s. co m
}

From source file:com.xengar.android.booksearch.ui.BookDetailActivity.java

private void setShareIntent() {
    ImageView ivImage = (ImageView) findViewById(R.id.ivBookCover);
    final TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
    // Get access to the URI for the bitmap
    Uri bmpUri = getLocalBitmapUri(ivImage);
    // Construct a ShareIntent with link to image
    Intent shareIntent = new Intent();
    // Construct a ShareIntent with link to image
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("*/*");
    shareIntent.putExtra(Intent.EXTRA_TEXT, (String) tvTitle.getText());
    shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
    // Launch share menu
    startActivity(Intent.createChooser(shareIntent, "Share Image"));
}

From source file:com.example.cuisoap.agrimac.homePage.demand.machineSelectDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    View view = inflater.inflate(R.layout.dialog_select_machine, container);
    list = (ListView) view.findViewById(R.id.machine_select_list);
    adapter = new machineSelectAdapter(mContext);
    data = new ArrayList<>();
    list.setAdapter(adapter);//from  w  w  w.  j a v a 2 s  . c  o m
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            JSONObject jo = new JSONObject();
            HashMap<String, String> item = (HashMap<String, String>) adapter.getItem(position);
            Intent i = new Intent();
            i.setAction("select_machine");
            i.putExtra("id", item.get("id"));
            i.putExtra("name", item.get("machine_name"));
            mContext.sendBroadcast(i);
            dismiss();
        }
    });
    Message m = Message.obtain();
    JSONObject o = new JSONObject();
    try {
        o.put("status", 0);
        JSONArray oo = new JSONArray("[{\n" + "    \"driveType\": \"\",\n"
                + "    \"driverName\": \"p\",\n" + "    \"driverAge\": \"p\",\n"
                + "    \"driverGender\": \"female\",\n" + "    \"driverLicenseType\": \"R\",\n"
                + "    \"driverLicense\": \"/sdcard/agrimac/driver2016_05_31_09_38_15.png\",\n"
                + "    \"machineType\": \"\",\n" + "    \"machineName\": \"p\",\n"
                + "    \"machinePower\": \"1\",\n" + "    \"passengerNum\": \"1\",\n"
                + "    \"wheelDistance\": \"1\",\n" + "    \"checkTime\": \"1\",\n"
                + "    \"payType\": \"loan\",\n" + "    \"machinePowerType\": \"\",\n"
                + "    \"machineLicense1\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_34.png\",\n"
                + "    \"machineLicense2\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_37.png\",\n"
                + "    \"leaseMonth\": \"1\",\n" + "    \"leaseTime\": \"1\",\n"
                + "    \"workCondition\": \"\",\n" + "    \"needType\": \"all\",\n"
                + "    \"houseType\": \"normal_house\",\n" + "    \"id\": \"1\"\n" + "}]");
        o.put("data", oo);
        m.obj = o;
        m.setTarget(h);
        m.sendToTarget();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return view;
}

From source file:com.horizondigital.delta.UpdateService.java

public static PendingIntent alarmPending(Context context, int id) {
    Intent intent = new Intent(context, UpdateService.class);
    intent.setAction(ACTION_ALARM);
    intent.putExtra(EXTRA_ALARM_ID, id);
    return PendingIntent.getService(context, id, intent, 0);
}

From source file:gov.wa.wsdot.android.wsdot.service.HighwayAlertsSyncService.java

@SuppressLint("SimpleDateFormat")
@Override/*from   w  w  w .  j  ava2  s  . c o  m*/
protected void onHandleIntent(Intent intent) {
    ContentResolver resolver = getContentResolver();
    Cursor cursor = null;
    long now = System.currentTimeMillis();
    boolean shouldUpdate = true;
    String responseString = "";
    DateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy h:mm a");

    /** 
     * Check the cache table for the last time data was downloaded. If we are within
     * the allowed time period, don't sync, otherwise get fresh data from the server.
     */
    try {
        cursor = resolver.query(Caches.CONTENT_URI, projection, Caches.CACHE_TABLE_NAME + " LIKE ?",
                new String[] { "highway_alerts" }, null);

        if (cursor != null && cursor.moveToFirst()) {
            long lastUpdated = cursor.getLong(0);
            //long deltaMinutes = (now - lastUpdated) / DateUtils.MINUTE_IN_MILLIS;
            //Log.d(DEBUG_TAG, "Delta since last update is " + deltaMinutes + " min");
            shouldUpdate = (Math.abs(now - lastUpdated) > (5 * DateUtils.MINUTE_IN_MILLIS));
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    // Tapping the refresh button will force a data refresh.
    boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false);

    if (shouldUpdate || forceUpdate) {

        try {
            URL url = new URL(HIGHWAY_ALERTS_URL);
            URLConnection urlConn = url.openConnection();

            BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
            String jsonFile = "";
            String line;

            while ((line = in.readLine()) != null) {
                jsonFile += line;
            }

            in.close();

            JSONObject obj = new JSONObject(jsonFile);
            JSONObject result = obj.getJSONObject("alerts");
            JSONArray items = result.getJSONArray("items");
            List<ContentValues> alerts = new ArrayList<ContentValues>();

            int numItems = items.length();
            for (int j = 0; j < numItems; j++) {
                JSONObject item = items.getJSONObject(j);
                JSONObject startRoadwayLocation = item.getJSONObject("StartRoadwayLocation");
                ContentValues alertData = new ContentValues();

                alertData.put(HighwayAlerts.HIGHWAY_ALERT_ID, item.getString("AlertID"));
                alertData.put(HighwayAlerts.HIGHWAY_ALERT_HEADLINE, item.getString("HeadlineDescription"));
                alertData.put(HighwayAlerts.HIGHWAY_ALERT_CATEGORY, item.getString("EventCategory"));
                alertData.put(HighwayAlerts.HIGHWAY_ALERT_PRIORITY, item.getString("Priority"));
                alertData.put(HighwayAlerts.HIGHWAY_ALERT_LATITUDE, startRoadwayLocation.getString("Latitude"));
                alertData.put(HighwayAlerts.HIGHWAY_ALERT_LONGITUDE,
                        startRoadwayLocation.getString("Longitude"));
                alertData.put(HighwayAlerts.HIGHWAY_ALERT_ROAD_NAME,
                        startRoadwayLocation.getString("RoadName"));
                alertData.put(HighwayAlerts.HIGHWAY_ALERT_LAST_UPDATED, dateFormat
                        .format(new Date(Long.parseLong(item.getString("LastUpdatedTime").substring(6, 19)))));

                alerts.add(alertData);
            }

            // Purge existing highway alerts covered by incoming data
            resolver.delete(HighwayAlerts.CONTENT_URI, null, null);
            // Bulk insert all the new highway alerts
            resolver.bulkInsert(HighwayAlerts.CONTENT_URI, alerts.toArray(new ContentValues[alerts.size()]));
            // Update the cache table with the time we did the update
            ContentValues values = new ContentValues();
            values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis());
            resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + " LIKE ?",
                    new String[] { "highway_alerts" });

            responseString = "OK";
        } catch (Exception e) {
            Log.e(DEBUG_TAG, "Error: " + e.getMessage());
            responseString = e.getMessage();
        }
    } else {
        responseString = "NOP";
    }

    Intent broadcastIntent = new Intent();
    broadcastIntent.setAction("gov.wa.wsdot.android.wsdot.intent.action.HIGHWAY_ALERTS_RESPONSE");
    broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    broadcastIntent.putExtra("responseString", responseString);
    sendBroadcast(broadcastIntent);
}

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

/**
 * Perform sync.//from  www  . j  a va2  s  . c  o 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) {
    // TODO Auto-generated method stub
    try {
        UserGroupsDb usergroups = new UserGroupsDb(context);
        Intent intent = new Intent();
        intent.setAction(SyncFinishReceiver.SYNC_FINISH);
        if (OpenERPServerConnection.isNetworkAvailable(context)) {
            Log.i(TAG + "::performSync()", "Sync with Server Started");
            OEHelper oe = usergroups.getOEInstance();
            if (oe.syncWithServer(usergroups, null, false, false)) {
                MailFollowerDb group_follower = new MailFollowerDb(context);
                OEHelper oe_1 = group_follower.getOEInstance();
                JSONObject domain = new JSONObject();
                int partner_id = Integer.parseInt(OpenERPAccountManager.currentUser(context).getPartner_id());
                domain.accumulate("domain", new JSONArray("[[\"partner_id\", \"=\", " + partner_id
                        + "],[\"res_model\",\"=\", \"" + usergroups.getModelName() + "\"]]"));

                if (oe_1.syncWithServer(group_follower, domain, false, false)) {
                    Log.i(TAG, "UserGroups Sync Finished");
                    MailFollowerDb follower = new MailFollowerDb(context);
                    List<HashMap<String, Object>> user_groups = follower.executeSQL(follower.getModelName(),
                            new String[] { "res_id" },
                            new String[] { "partner_id = ?", "AND", "res_model = ?" },
                            new String[] { partner_id + "", "mail.group" });
                    JSONArray group_ids = new JSONArray();
                    if (user_groups.size() > 0) {
                        for (HashMap<String, Object> row : user_groups) {
                            group_ids.put(Integer.parseInt(row.get("res_id").toString()));
                        }
                    }
                    context.sendBroadcast(intent);
                    Bundle bundle = new Bundle();
                    bundle.putString("group_ids", group_ids.toString());
                    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
                    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
                    ContentResolver.requestSync(account, MessageProvider.AUTHORITY, bundle);
                }

            }

        } else {
            Log.e("OpenERPServerConnection", "Unable to Connect with server");
        }

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

}

From source file:com.pureexe.calinoius.environment.camera.fragment.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    dataManager = new DataManager(getActivity());

    try {//from w w  w. jav a 2  s .  co  m
        // Use Try catch Exception to avoid force close with CM's Privacy Guard
        Cursor c = getActivity().getApplication().getContentResolver()
                .query(ContactsContract.Profile.CONTENT_URI, null, null, null, null);
        c.moveToFirst();
        dataManager.setString("Researcher", c.getString(c.getColumnIndex("display_name")));
    } catch (Exception e) {
        dataManager.setString("Researcher", "Unknown");
    }
    GridView gridview = (GridView) rootView.findViewById(R.id.gridView1);
    gridview.setAdapter(new HomePageAdapter(getActivity()));
    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            if (position == 0) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "UserFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
            if (position == 1) {
                Intent intent = new Intent(getActivity(), EnvironmentCameraActivity.class);
                startActivity(intent);
            }
            if (position == 2) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "EXIFreadFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
            if (position == 3) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "SettingPreferenceFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
            if (position == 4) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "HelpFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
            if (position == 5) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "AboutFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
        }
    });

    return rootView;
}

From source file:com.phonegap.bossbolo.plugin.BoloPlugin.java

public void uninstallBPP() {
    final String packageName = "com.bossbolo.bppapp";
    final CordovaPlugin currentPlugin = (CordovaPlugin) this;
    try {//  w  w  w . jav a  2s .  c  om
        ApplicationInfo info = this.cordova.getActivity().getPackageManager().getApplicationInfo(packageName,
                PackageManager.GET_UNINSTALLED_PACKAGES);
        new AlertDialog.Builder(this.cordova.getActivity()).setTitle("??").setMessage(
                "?\n    ?B++???B++????B++????\n    ???")
                .setPositiveButton("", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialoginterface, int i) {
                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_DELETE);
                        intent.setData(Uri.parse("package:" + packageName));
                        currentPlugin.cordova.startActivityForResult(currentPlugin, intent, 2298816);
                    }
                }).show();
    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}