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:jp.co.conit.sss.sn.ex2.fragment.MessagesFragment.java

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

    setEmptyText(getString(R.string.no_messages));

    // EmptyText????INTERNAL_EMPTY_ID??TextView?????
    // INTERNAL_EMPTY_ID?ListFragment??EmptyText?ID?????????????ListFragment???????
    TextView tx = (TextView) getView().findViewById(INTERNAL_EMPTY_ID);
    int color = getResources().getColor(R.color.settings_text_color);
    tx.setTextColor(color);//from   ww  w . j  ava2s  .  c om

    getListView().setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            PushMessage pm = (PushMessage) parent.getItemAtPosition(position);
            String userData = pm.getUserData();
            Intent activityIntent = new Intent();
            if (StringUtil.isEmpty(userData) || userData.equals("null")) {
                return;
            } else {
                if (userData.startsWith("http")) {
                    activityIntent.setAction(Intent.ACTION_VIEW);
                    activityIntent.setData(Uri.parse(userData));
                } else {
                    activityIntent.setClass(mParentActivity, UserDataActivity.class);
                    activityIntent.putExtra("option", userData);
                }
            }
            startActivity(activityIntent);
        }
    });

    obtainMessagesAsync();

}

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

private void doUpdateSelf() {
    Intent intent = new Intent();
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("file://" + TMP_UPDATE_FILE), "application/vnd.android.package-archive");

    startActivityForResult(intent, UPDATE_SELF);
}

From source file:info.guardianproject.otr.app.im.app.WelcomeActivity.java

void handleIntentAPILaunch(Intent srcIntent) {
    Intent intent = new Intent(this, ImUrlActivity.class);
    intent.setAction(srcIntent.getAction());

    if (srcIntent.getData() != null)
        intent.setData(srcIntent.getData());

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (srcIntent.getExtras() != null)
        intent.putExtras(srcIntent.getExtras());
    startActivity(intent);/*  w ww  .  j  a v a 2s  .c  o  m*/

    setIntent(null);
    finish();
}

From source file:com.mobicage.rogerthat.registration.AbstractRegistrationActivity.java

public void startMainActivity(boolean directly) {
    if (!directly && AppConstants.PROFILE_SHOW_GENDER_AND_BIRTHDATE && !getAgeAndGenderSet()) {
        Intent intent = new Intent(mActivity, MainActivity.class);
        intent.setAction(MainActivity.ACTION_COMPLETE_PROFILE);
        intent.setFlags(MainActivity.FLAG_CLEAR_STACK_SINGLE_TOP);
        startActivity(intent);/*from  ww w.ja v a2s.c  o m*/
    } else {
        Intent intent = new Intent(mActivity, MainActivity.class);
        intent.setAction(MainActivity.ACTION_REGISTERED);
        startActivity(intent);
    }

    mActivity.finish();
}

From source file:org.yaoha.YaohaActivity.java

public boolean editFavs(MenuItem item, final ImageButton btn, final TextView tv) {
    if (item.getTitle() == EDIT_FAV_STRING) {
        openFavMenu(btn, tv);//from  w  w w.  j  ava2s  .co  m
    } else if (item.getTitle() == EDIT_FAV_PIC) {
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        actualButton = btn; //workaround, there must be a better way
        startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);
    } else if (item.getTitle() == REMOVE_FAV) {
        tv.setText(getText(R.string.add_favorite));
        btn.setImageResource(R.drawable.plus_sign_small);
        String tmp = "";
        final Editor edit = prefs.edit();
        if (btn.getId() == button_favorite_1.getId()) {
            tmp = "saved_fav_1_text";
        } else if (btn.getId() == button_favorite_2.getId()) {
            tmp = "saved_fav_2_text";
        } else if (btn.getId() == button_favorite_3.getId()) {
            tmp = "saved_fav_3_text";
        } else if (btn.getId() == button_favorite_4.getId()) {
            tmp = "saved_fav_4_text";
        } else if (btn.getId() == button_favorite_5.getId()) {
            tmp = "saved_fav_5_text";
        } else if (btn.getId() == button_favorite_6.getId()) {
            tmp = "saved_fav_6_text";
        }
        edit.remove(tmp);
        edit.commit();
    } else {
        Toast.makeText(this, "Placeholder - You schould never see this.", Toast.LENGTH_SHORT).show();
        return false;
    }
    return super.onContextItemSelected(item);
}

From source file:com.gcm.client.GcmHelper.java

/**
 * Initialize the GcmHelper class. To be called from the application class onCreate or from the
 * onCreate of the main activity/*from  w  w  w.j a  v a  2  s  .c  o m*/
 *
 * @param context An instance of the Application Context
 */
public synchronized void init(@NonNull Context context) {
    if (!isGooglePlayservicesAvailable(context)) {
        throw new IllegalArgumentException("Not using the recommended Play Services version");
    }
    //get the GCM sender id from strings.xml
    if (TextUtils.isEmpty(senderID)) {
        int id = context.getResources().getIdentifier("gcm_authorized_entity", "string",
                context.getPackageName());
        senderID = context.getResources().getString(id);
    }

    if (TextUtils.isEmpty(senderID)) {
        throw new IllegalArgumentException("No SenderId provided!! Cannot instantiate");
    }

    SharedPreferences localPref = getSharedPreference(context);
    //get topics array
    if (localPref.contains(PREF_KEY_SUBSCRIPTION)) {
        String subscription = localPref.getString(PREF_KEY_SUBSCRIPTION, null);
        if (!TextUtils.isEmpty(subscription)) {
            try {
                JSONArray array = new JSONArray(subscription);
                int length = array.length();
                topics = new ArrayList<>();
                for (int i = 0; i < length; i++) {
                    topics.add(array.getString(i));
                }
            } catch (JSONException ignored) {
                if (DEBUG_ENABLED)
                    Log.e(TAG, "init: while processing subscription list", ignored);
            }
        }
    }

    boolean registrationReq = true;
    if (localPref.contains(PREF_KEY_TOKEN)) {
        pushToken = localPref.getString(PREF_KEY_TOKEN, null);
        if (!TextUtils.isEmpty(pushToken)) {
            registrationReq = false;
            //don't pass token if already present
        }
    }
    if (registrationReq) {
        //register for push token
        Intent registration = new Intent(context, RegistrationIntentService.class);
        registration.setAction(RegistrationIntentService.ACTION_REGISTER);
        context.startService(registration);
    }
    //check if debug build and enable DEBUG MODE
    DEBUG_ENABLED = (0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
    initialized = true;
}

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

@Override
protected void onListItemClick(ListView l, View v, final int position, long id) {

    super.onListItemClick(l, v, position, id);

    Vector<String> tmp_get = db.getApk(apk_lst.get(position).apkid);

    String tmp_path = this.getString(R.string.icons_path) + apk_lst.get(position).apkid;
    File test_icon = new File(tmp_path);

    LayoutInflater li = LayoutInflater.from(this);
    View view = li.inflate(R.layout.alertscroll, null);
    Builder alrt = new AlertDialog.Builder(this).setView(view);
    final AlertDialog p = alrt.create();
    if (test_icon.exists() && test_icon.length() > 0) {
        p.setIcon(new BitmapDrawable(tmp_path));
    } else {//from w w w. ja va2s.  c o m
        p.setIcon(android.R.drawable.sym_def_app_icon);
    }
    p.setTitle(apk_lst.get(position).name);
    TextView t1 = (TextView) view.findViewById(R.id.n11);
    t1.setText(tmp_get.firstElement());
    TextView t2 = (TextView) view.findViewById(R.id.n22);
    t2.setText(tmp_get.get(1));
    TextView t3 = (TextView) view.findViewById(R.id.n33);
    t3.setText(tmp_get.get(2));
    TextView t4 = (TextView) view.findViewById(R.id.n44);
    t4.setText(tmp_get.get(3));
    TextView t5 = (TextView) view.findViewById(R.id.n55);
    String tmpi = db.getDescript(apk_lst.get(position).apkid);
    if (!(tmpi == null)) {
        t5.setText(tmpi);
    } else {
        t5.setText("No info availale on server. Search market by pressing the button below for more info.");
    }

    p.setButton2("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    if (tmp_get.get(2).equalsIgnoreCase("\tno\n")) {
        p.setButton(getString(R.string.install), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                p.dismiss();
                new Thread() {
                    public void run() {
                        String apk_pkg = downloadFile(position);
                        if (apk_pkg == null) {
                            Message msg = new Message();
                            msg.arg1 = 1;
                            download_handler.sendMessage(msg);
                            download_error_handler.sendEmptyMessage(0);
                        } else {
                            installApk(apk_pkg, position);
                        }
                    }
                }.start();
            }
        });
        p.setButton3("Search Market", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                p.dismiss();
                Intent intent = new Intent();
                intent.setAction(android.content.Intent.ACTION_VIEW);
                intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid));
                startActivity(intent);
            }
        });
    } else {
        p.setButton(getString(R.string.rem), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String apk_pkg = apk_lst.get(position).apkid;
                removeApk(apk_pkg, position);
            }
        });
        if (apk_lst.get(position).status == 2) {
            p.setButton3(getString(R.string.update), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    p.dismiss();
                    new Thread() {
                        public void run() {
                            String apk_pkg = downloadFile(position);
                            if (apk_pkg == null) {
                                //Toast.makeText(RemoteInSearch.this, "Could not connect to server!", Toast.LENGTH_LONG).show();
                                Message msg = new Message();
                                msg.arg1 = 1;
                                download_handler.sendMessage(msg);
                                download_error_handler.sendEmptyMessage(0);
                            } else {
                                installApk(apk_pkg, position);
                            }
                        }
                    }.start();
                }
            });
        } else {
            p.setButton3("Search Market", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    p.dismiss();
                    Intent intent = new Intent();
                    intent.setAction(android.content.Intent.ACTION_VIEW);
                    intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid));
                    startActivity(intent);
                }
            });
        }
    }
    p.show();
}

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

private void setNotification(int apkidHash, int progress) {

    String apkid = notifications.get(apkidHash).get("apkid");
    int size = Integer.parseInt(notifications.get(apkidHash).get("intSize"));
    String version = notifications.get(apkidHash).get("version");

    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.download_notification);
    contentView.setImageViewResource(R.id.download_notification_icon, R.drawable.ic_notification);
    contentView.setTextViewText(R.id.download_notification_name,
            getString(R.string.download_alrt) + " " + apkid + " v." + version);
    contentView.setProgressBar(R.id.download_notification_progress_bar, size * KBYTES_TO_BYTES, progress,
            false);// w ww .j a v  a 2 s. co m

    Intent onClick = new Intent();
    onClick.setClassName("cm.aptoide.pt", "cm.aptoide.pt");
    onClick.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
    onClick.setAction("cm.aptoide.pt.FROM_NOTIFICATION");

    // The PendingIntent to launch our activity if the user selects this notification
    PendingIntent onClickAction = PendingIntent.getActivity(context, 0, onClick, 0);

    Notification notification = new Notification(R.drawable.ic_notification,
            getString(R.string.download_alrt) + " " + apkid, System.currentTimeMillis());
    notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
    notification.contentView = contentView;

    // Set the info for the notification panel.
    notification.contentIntent = onClickAction;
    //       notification.setLatestEventInfo(this, getText(R.string.app_name), getText(R.string.add_repo_text), contentIntent);

    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    // Send the notification.
    // We use the position because it is a unique number.  We use it later to cancel.
    notificationManager.notify(apkidHash, notification);

    //      Log.d("Aptoide-DownloadQueueService", "Notification Set");
}