Example usage for android.content Intent setClass

List of usage examples for android.content Intent setClass

Introduction

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

Prototype

public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) 

Source Link

Document

Convenience for calling #setComponent(ComponentName) with the name returned by a Class object.

Usage

From source file:de.vanita5.twittnuker.util.Utils.java

public static void openMap(final Context context, final double latitude, final double longitude) {
    if (context == null || !new ParcelableLocation(latitude, longitude).isValid())
        return;//from   w w w .  j  av  a 2s.  c om
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_TWITTNUKER);
    builder.authority(AUTHORITY_MAP);
    builder.appendQueryParameter(QUERY_PARAM_LAT, String.valueOf(latitude));
    builder.appendQueryParameter(QUERY_PARAM_LNG, String.valueOf(longitude));
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    intent.setClass(context, MapViewerActivity.class);
    if (context instanceof Activity) {
        SwipebackActivityUtils.startSwipebackActivity((Activity) context, intent);
    } else {
        context.startActivity(intent);
    }
}

From source file:com.hichinaschool.flashcards.anki.DeckPicker.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    mDontSaveOnStop = false;//from w  w w .j  a v a2s.c o m
    if (resultCode == RESULT_MEDIA_EJECTED) {
        showDialog(DIALOG_SD_CARD_NOT_MOUNTED);
        return;
    } else if (resultCode == RESULT_DB_ERROR) {
        handleDbError();
        return;
    }
    if (requestCode == SHOW_STUDYOPTIONS && resultCode == RESULT_OK) {
        loadCounts();
    } else if (requestCode == ADD_NOTE && resultCode != RESULT_CANCELED) {
        loadCounts();
    } else if (requestCode == BROWSE_CARDS
            && (resultCode == Activity.RESULT_OK || resultCode == Activity.RESULT_CANCELED)) {
        loadCounts();
    } else if (requestCode == ADD_CRAM_DECK) {
        // TODO: check, if ok has been clicked
        loadCounts();
    } else if (requestCode == REPORT_ERROR) {
        showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(getBaseContext()), 4);
    } else if (requestCode == SHOW_INFO_UPGRADE_DECKS) {
        if (intent != null && intent.hasExtra(Info.TYPE_UPGRADE_STAGE)) {
            int type = intent.getIntExtra(Info.TYPE_UPGRADE_STAGE, Info.UPGRADE_SCREEN_BASIC1);
            if (type == Info.UPGRADE_CONTINUE) {
                showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(getBaseContext()), 3);
            } else {
                showUpgradeScreen(true, type, !intent.hasExtra(Info.TYPE_ANIMATION_RIGHT));
            }
        } else {
            if (resultCode == RESULT_OK) {
                if (mOpenCollectionDialog != null && mOpenCollectionDialog.isShowing()) {
                    mOpenCollectionDialog.dismiss();
                }
                if (AnkiDroidApp.colIsOpen()) {
                    AnkiDroidApp.closeCollection(true);
                }
                AnkiDroidApp.openCollection(AnkiDroidApp.getCollectionPath());
                loadCounts();
            } else {
                finishWithAnimation();
            }
        }
    } else if (requestCode == SHOW_INFO_WELCOME || requestCode == SHOW_INFO_NEW_VERSION) {
        if (resultCode == RESULT_OK) {
            showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(getBaseContext()),
                    requestCode == SHOW_INFO_WELCOME ? 1 : 2);
        } else {
            finishWithAnimation();
        }
    } else if (requestCode == PREFERENCES_UPDATE) {
        String oldPath = mPrefDeckPath;
        SharedPreferences pref = restorePreferences();
        String newLanguage = pref.getString("language", "");
        if (AnkiDroidApp.setLanguage(newLanguage)) {
            mInvalidateMenu = true;
        }
        if (mNotMountedDialog != null && mNotMountedDialog.isShowing()
                && pref.getBoolean("internalMemory", false)) {
            showStartupScreensAndDialogs(pref, 0);
        } else if (!mPrefDeckPath.equals(oldPath)) {
            loadCollection();
        }
        // if (resultCode == StudyOptions.RESULT_RESTART) {
        // setResult(StudyOptions.RESULT_RESTART);
        // finishWithAnimation();
        // } else {
        // SharedPreferences preferences = PrefSettings.getSharedPrefs(getBaseContext());
        // BackupManager.initBackup();
        // if (!mPrefDeckPath.equals(preferences.getString("deckPath", AnkiDroidApp.getStorageDirectory())) ||
        // mPrefDeckOrder != Integer.parseInt(preferences.getString("deckOrder", "0"))) {
        // // populateDeckList(preferences.getString("deckPath", AnkiDroidApp.getStorageDirectory()));
        // }
        // }
    } else if (requestCode == REPORT_FEEDBACK && resultCode == RESULT_OK) {
    } else if (requestCode == LOG_IN_FOR_SYNC && resultCode == RESULT_OK) {
        sync();
    } else if (requestCode == LOG_IN_FOR_SHARED_DECK && resultCode == RESULT_OK) {
        addSharedDeck();
    } else if (requestCode == ADD_SHARED_DECKS) {
        if (intent != null) {
            mImportPath = intent.getStringExtra("importPath");
        }
        if (AnkiDroidApp.colIsOpen() && mImportPath != null) {
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_IMPORT, mImportAddListener,
                    new TaskData(AnkiDroidApp.getCol(), mImportPath, true));
            mImportPath = null;
        }
    } else if (requestCode == REQUEST_REVIEW) {
        // Log.i(AnkiDroidApp.TAG, "Result code = " + resultCode);
        switch (resultCode) {
        default:
            // do not reload counts, if activity is created anew because it has been before destroyed by android
            loadCounts();
            break;
        case Reviewer.RESULT_NO_MORE_CARDS:
            mDontSaveOnStop = true;
            Intent i = new Intent();
            i.setClass(this, StudyOptionsActivity.class);
            i.putExtra("onlyFnsMsg", true);
            startActivityForResult(i, SHOW_STUDYOPTIONS);
            if (AnkiDroidApp.SDK_VERSION > 4) {
                ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.RIGHT);
            }
            break;
        }

    }

    // workaround for hidden dialog on return
    BroadcastMessages.showDialog();
}

From source file:com.hichinaschool.flashcards.anki.DeckPicker.java

private void openStudyOptions(long deckId, Bundle cramInitialConfig) {
    if (mFragmented) {
        setStudyContentView(deckId, cramInitialConfig);
    } else {/*from  w w  w.  jav a 2  s  .  co m*/
        mDontSaveOnStop = true;
        Intent intent = new Intent();
        intent.putExtra("index", deckId);
        intent.putExtra("cramInitialConfig", cramInitialConfig);
        intent.setClass(this, StudyOptionsActivity.class);
        // if (deckId != 0) {
        // intent.putExtra(EXTRA_DECK_ID, deckId);
        // }
        startActivityForResult(intent, SHOW_STUDYOPTIONS);
        // if (deckId != 0) {
        // if (UIUtils.getApiLevel() > 4) {
        // ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.NONE);
        // }
        // } else {
        if (AnkiDroidApp.SDK_VERSION > 4) {
            ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.LEFT);
        }
        // }
    }
}

From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java

private void handleVideoRecord() {

    Intent intent = new Intent();
    intent.setClass(getActivity(), VideoRecordActivity.class);
    startActivityForResult(intent, GlobalConstant.ACTIVITY_FOR_RESULT_VIDEORECORD);
}

From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java

/**
 * ????//  w ww  .java 2s  . c o m
 */
private void initView() {
    mListView = (ListView) findViewById(R.id.chatting_history_lv);
    mListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
    mListView.setItemsCanFocus(false);
    mListView.setOnScrollListener(this);
    mListView.setKeepScreenOn(false);
    mListView.setStackFromBottom(false);
    mListView.setFocusable(false);
    mListView.setFocusableInTouchMode(false);
    mListView.setOnItemLongClickListener(mOnItemLongClickListener);
    registerForContextMenu(mListView);

    mListViewHeadView = getChattingActivity().getLayoutInflater().inflate(R.layout.chatting_list_header, null);
    mListView.addHeaderView(mListViewHeadView);
    mListView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            hideSoftKeyboard();
            if (mChattingFooter != null) {
                // After the input method you can use the record button.
                // mGroudChatRecdBtn.setEnabled(true);
                // mChatFooter.setMode(1);
                mChattingFooter.hideBottomPanel();
            }
            return false;
        }
    });

    mMsgLayoutMask = findViewById(R.id.message_layout_mask);
    mMsgLayoutMask.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideMsgLayoutMask();
            mListView.setSelection(mListView.getCount() - 1);
            return true;
        }
    });
    /************************************************************************************************************/
    mECPullDownView = (ECPullDownView) findViewById(R.id.chatting_pull_down_view);
    mECPullDownView.setTopViewInitialize(true);
    mECPullDownView.setIsCloseTopAllowRefersh(false);
    mECPullDownView.setHasbottomViewWithoutscroll(false);
    mECPullDownView.setOnRefreshAdapterDataListener(mOnRefreshAdapterDataListener);
    mECPullDownView.setOnListViewTopListener(mOnListViewTopListener);
    mECPullDownView.setOnListViewBottomListener(mOnListViewBottomListener);

    // ????
    mChattingFooter = (CCPChattingFooter2) findViewById(R.id.nav_footer);
    // ???????
    mChattingFooter.setOnChattingFooterLinstener(mChattingFooterImpl);
    // ??????
    mChattingFooter.setOnChattingPanelClickListener(mChattingPanelImpl);
    // ?????
    mChattingFooter.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            LogUtil.d(TAG, "[onTextChanged]");
            String text = String.valueOf(s);
            String value = text.substring(start, start + count);
            if (("@".equals(value) && isPeerChat()) && !text.equals(mChattingFooter.getLastContent())
                    && !mChattingFooter.isSetAtSomeoneing()) {
                mChattingFooter.setLastContent(text);
                mChattingFooter.setInsertPos(start + 1);
                boolean handler = (text == null || start < 0 || text.length() < start);
                if (!handler) {
                    Intent action = new Intent();
                    action.setClass(getChattingActivity(), AtSomeoneUI.class);
                    action.putExtra(AtSomeoneUI.EXTRA_GROUP_ID, mRecipients);
                    action.putExtra(AtSomeoneUI.EXTRA_CHAT_USER, CCPAppManager.getClientUser().getUserId());
                    startActivityForResult(action, 212);
                }
                return;
            } else if (!text.equals(mChattingFooter.getLastContent())) {
                mChattingFooter.setLastContent(text);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
    mChattingAdapter = new ChattingListAdapter2(getActivity(), ECMessage.createECMessage(ECMessage.Type.NONE),
            mRecipients, mThread);
    mListView.setAdapter(mChattingAdapter);
}

From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java

private Boolean handleContentMenuClick(int convresion, int position, int arr) {
    if (mChattingAdapter != null) {
        int headerViewsCount = mListView.getHeaderViewsCount();
        if (convresion < headerViewsCount) {
            return false;
        }// w w  w  .ja va2 s.  co m
        int _position = convresion - headerViewsCount;

        if (mChattingAdapter == null || mChattingAdapter.getItem(_position) == null) {
            return false;
        }
        final ECMessage msg = mChattingAdapter.getItem(_position);
        LogUtil.d(TAG, "ECMessage  get msgId is =" + msg.getMsgId());
        msg.setSessionId(mRecipients);

        String[] resarr = getResources().getStringArray(arr);
        String i = resarr[position];

        if ("".endsWith(i)) {
            doDelMsgTips(msg, _position);
        } else if ("".endsWith(i)) {
            ECChatManager chatManager = SDKCoreHelper.getECChatManager();
            if (chatManager == null || msg == null) {
                return null;
            }

            if (msg.getDirection() == ECMessage.Direction.SEND) {

                chatManager.revokeMessage(msg, new ECChatManager.OnRevokeMessageListener() {
                    @Override
                    public void onRevokeMessage(ECError error, ECMessage message) {
                        if (error.errorCode == SdkErrorCode.REQUEST_SUCCESS) {
                            ToastUtil.showMessage("?");
                            IMessageSqlManager.insertSysMessage("??", mRecipients);
                            IMessageSqlManager.delSingleMsg(msg.getMsgId());
                            mChattingAdapter.notifyChange();
                        } else {
                            ToastUtil.showMessage("" + error.errorCode);
                        }
                        Log.d(TAG, "message:" + message);
                    }
                });
            }
        } else if ("??".endsWith(i)) {
            if (msg.getType() == ECMessage.Type.TXT) {
                ECTextMessageBody body = (ECTextMessageBody) msg.getBody();
                ClipboardUtils.copyFromEdit(getActivity(), getString(R.string.app_pic), body.getMessage());
                ToastUtil.showMessage(R.string.app_copy_ok);
            } else {
                ECChatManager chatManager = SDKCoreHelper.getECChatManager();
                if (chatManager == null || msg == null) {
                    return null;
                }

                if (msg.getDirection() == ECMessage.Direction.SEND) {
                    chatManager.revokeMessage(msg, new ECChatManager.OnRevokeMessageListener() {
                        @Override
                        public void onRevokeMessage(ECError error, ECMessage message) {
                            if (error.errorCode == SdkErrorCode.REQUEST_SUCCESS) {

                                ToastUtil.showMessage("?");
                                IMessageSqlManager.insertSysMessage("??", mRecipients);
                                IMessageSqlManager.delSingleMsg(msg.getMsgId());
                                mChattingAdapter.notifyChange();
                            } else {
                                ToastUtil.showMessage("" + error.errorCode);
                            }
                        }
                    });
                }

            }

        } else if ("".endsWith(i)) {
            ECAlertDialog.buildAlert(getActivity(), "", "", "",
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                            Intent action = new Intent();
                            action.setClass(getChattingActivity(), ECMessageFeedUI.class);
                            msg.setSessionId(mRecipients);
                            action.putExtra("type", 1);
                            ECMessageFeedUI.message = msg;
                            startActivity(action);

                        }
                    }, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent action = new Intent();
                            action.setClass(getChattingActivity(), ECMessageFeedUI.class);
                            msg.setSessionId(mRecipients);
                            ECMessageFeedUI.message = msg;
                            action.putExtra("type", 2);
                            startActivity(action);

                        }
                    }).show();

        } else if ("?".endsWith(i)) {
            searchTargetCollectUser(msg);
        }
    }
    return null;
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void openMediaDirectly(final Context context, final long accountId, final ParcelableStatus status,
        final ParcelableDirectMessage message, final ParcelableMedia current, final ParcelableMedia[] media) {
    if (context == null || media == null)
        return;/*from w w w.j a v  a  2 s.  c  om*/
    final Intent intent = new Intent(INTENT_ACTION_VIEW_MEDIA);
    intent.putExtra(EXTRA_ACCOUNT_ID, accountId);
    intent.putExtra(EXTRA_CURRENT_MEDIA, current);
    intent.putExtra(EXTRA_MEDIA, media);
    if (status != null) {
        intent.putExtra(EXTRA_STATUS, status);
    }
    if (message != null) {
        intent.putExtra(EXTRA_MESSAGE, message);
    }
    intent.setClass(context, MediaViewerActivity.class);
    context.startActivity(intent);
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void dial_click() {
    Intent intent = new Intent();
    intent.setClass(HomeScreen.this, PanicScreen.class);
    startActivity(intent);//from   w w w . j  a  va  2s .c o  m
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void scan_click(boolean taaScan) {
    Intent intent = new Intent();
    intent.setClass(HomeScreen.this, ScanBarCodeScreen.class);
    if (taaScan) {
        intent.putExtra("taaScan", "yes");
        intent.putExtra("tagScan", "no");
    } else {//from w w  w.j  av a  2  s. co m
        intent.putExtra("taaScan", "no");
        intent.putExtra("tagScan", "yes");
    }

    //clear the last tag scanned
    setlasttagScanned("");

    startActivity(intent);
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void show_diagnostics_dialog() {

    Intent diagIntent = new Intent();
    diagIntent.setClass(HomeScreen.this, diagnostics.class);

    startActivity(diagIntent);//from  w  w  w.  ja va  2  s  .  c o m

    /*
    show_alert_title = "Diagnostics";
    //if(sendData())
    {
       myDatabase.open();
         String logged = String.valueOf(myDatabase.getnumRecords());
       myDatabase.close();
               
       show_alert_message = "Session started at: " + Utility.getsessionStart().substring(9,14) + "\n" + 
           "on: " + Utility.getsessionStart().substring(0,5) + "\n" + 
           "Connected to server: " + Utility.isConnecting() + "\n" + 
           "Valid GPS: " + Utility.isvalidGps() + "  (" +  String.valueOf(GTConstants.locationInfoDTO.getNumSats()) + ")\n" +
           "Pending files: " + String.valueOf(Utility.getnumFiles( new File(GTConstants.sendfileFolder)))+ "\n" +
           "Logged events: " + logged;
    }
    //else
       //show_alert_message = "Start shift to run diagnostics";
                    
    showAlert(show_alert_title, show_alert_message, true);
            
    /*
     show_alert_message = "Session started" + "\n" + "  at: " + Utility.getsessionStart().format(new Date()).substring(9) + "\n" +
           "  on: " + Utility.getsessionStart().format(new Date()).substring(0,9) + "\n" + 
           "Connected to server: " + Utility.isConnecting() + "\n" + 
           "Valid GPS: " + Utility.isvalidGps() + "\n" +
           "Pending files: " + String.valueOf(Utility.getnumFiles( new File(GTConstants.sendfileFolder)));
     */
}