当前位置: 首页>>代码示例>>Java>>正文


Java Intent.getType方法代码示例

本文整理汇总了Java中android.content.Intent.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getType方法的具体用法?Java Intent.getType怎么用?Java Intent.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleShareIntent

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 处理接收到ShareIntent
 */
private void handleShareIntent() {
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (TextUtils.equals(Intent.ACTION_SEND, action) && !TextUtils.isEmpty(type)) {
        if (TextUtils.equals("text/plain", type)) {
            String content = intent.getStringExtra(Intent.EXTRA_TEXT);
            if (!TextUtils.isEmpty(content)) {
                onSendTextMessage(content);
            }
        } else if (type.startsWith("image/")) {
            Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (uri != null) {
                String path = FilePathUtils.getPath(mActivity, uri);
                if (!TextUtils.isEmpty(path)) {
                    //发送图片
                    onSendImageMessage(Collections.singletonList(new File(path)));
                }
            }
        }
    }
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:26,代码来源:KF5ChatActivity.java

示例2: parseIntent

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Parses the intent
 */
private void parseIntent(Intent intent) {
    final String action = intent.getAction();
    final String type = intent.getType();

    if (Intent.ACTION_VIEW.equals(action)
            || Intent.ACTION_EDIT.equals(action)
            || Intent.ACTION_PICK.equals(action)
            && type != null) {
        // Post event
       //newFileToOpen(new File(intent
       //        .getData().getPath()), "");
        Uri uri = intent.getData();
        GreatUri newUri = new GreatUri(uri, AccessStorageApi.getPath(this, uri), AccessStorageApi.getName(this, uri));
        newFileToOpen(newUri, "");
    } else if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("text/plain".equals(type)) {
            newFileToOpen(new GreatUri(Uri.EMPTY, "", ""), intent.getStringExtra(Intent.EXTRA_TEXT));
        }
    }
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:24,代码来源:MainActivity.java

示例3: doInBackground

import android.content.Intent; //导入方法依赖的package包/类
protected Void doInBackground(Void... regions) {
    Intent intent = getIntent();

    if (intent != null) {
        String s = intent.getType();
        if (s != null && s.indexOf("image/") != -1) {
            Uri data = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
            mImageName = "edit"+data.getLastPathSegment(); // TODO the wrong way to do this

            if (data != null) {
                InputStream input = null;
                try {
                    input = getContentResolver().openInputStream(data);
                    mDisplayedImage = BitmapFactory.decodeStream(input);

                    return null;
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }

            }
        }
    }

    getLocalImage();
    return null;
}
 
开发者ID:googlecodelabs,项目名称:style-transfer,代码行数:28,代码来源:MainActivity.java

示例4: setIntentFicUrl

import android.content.Intent; //导入方法依赖的package包/类
private void setIntentFicUrl() {
    ficUrl = "";
    Intent intent = getIntent();
    if (intent != null) {
        String intentType = intent.getType();
        String intentAction = intent.getAction();
        Log.d("ficsaveM/intentReceived", intentAction + " " + intent.toString());
        if (Intent.ACTION_SEND.equals(intentAction) && intentType != null && "text/plain".equals(intentType)) {
            Matcher m = Patterns.WEB_URL.matcher(intent.getStringExtra(Intent.EXTRA_TEXT));
            while (m.find()) {
                String url = m.group();
                ficUrl = url;
                Log.d("ficsaveM/setIntFicUrl", "URL extracted: " + url);

                mGTracker.send(new HitBuilders.EventBuilder()
                        .setCategory(MAIN_PAGE_CATEGORY)
                        .setAction("Fic Url Set")
                        .setLabel(URL_LABEL + ficUrl)
                        .setValue(1)
                        .build());
                Bundle bundle = new Bundle();
                bundle.putString("Url", ficUrl);
                mFTracker.logEvent("FicUrlSet", bundle);
            }

        }
    }
}
 
开发者ID:xRahul,项目名称:FicsaveMiddleware,代码行数:29,代码来源:MainActivity.java

示例5: dump

import android.content.Intent; //导入方法依赖的package包/类
public static void dump(Intent intent) {
    if (intent == null) {
        e("Intent is null");
        return;
    }

    e("Intent: action: %s", intent.getAction());

    if (intent.getPackage() != null) {
        e("  pkg: %s", intent.getPackage());
    }

    if (intent.getType() != null) {
        e("  type: %s", intent.getType());
    }

    if (intent.getComponent() != null) {
        e("  comp: %s", intent.getComponent().flattenToString());
    }

    if (intent.getDataString() != null) {
        e("  data: %s", intent.getDataString());
    }

    if (intent.getCategories() != null) {
        for (String cat : intent.getCategories()) {
            e("  cat: %s", cat);
        }
    }

    Bundle bundle = intent.getExtras();
    if (bundle != null) {
        for (String key : bundle.keySet()) {
            Object value = bundle.get(key);
            e("  extra: %s->%s", key, value);
        }
    }

}
 
开发者ID:NamTranDev,项目名称:CleanArchitechture,代码行数:40,代码来源:Logger.java

示例6: handleIntent

import android.content.Intent; //导入方法依赖的package包/类
private void handleIntent() {
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (intent == null) {
        return;
    }
    if (type == null) {
        return;
    }
    //getStringExtra() may return null
    if (Intent.ACTION_SEND.equals(action) && type.equals("text/plain")) {
        mTextToProcess = intent.getStringExtra(Intent.EXTRA_TEXT);
        mTargetWord = intent.getStringExtra(Constant.INTENT_ANKIHELPER_TARGET_WORD);
        //mFbReaderBookmarkId = intent.getStringExtra(Constant.INTENT_ANKIHELPER_FBREADER_BOOKMARK_ID);
        String noteEditedByUser = intent.getStringExtra(Constant.INTENT_ANKIHELPER_NOTE);
        String updateId = intent.getStringExtra(Constant.INTENT_ANKIHELPER_NOTE_ID);
    }
    if(Intent.ACTION_PROCESS_TEXT.equals(action)&&type.equals("text/plain"))
    {
    mTextToProcess = intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT);
    }
    if(mTextToProcess ==null)
    {
    return;
    }
    populateWordSelectBox();
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:29,代码来源:PopupActivity.java

示例7: onCreate

import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    /* Animate the views */
    MaterialIn.animate(rootView);

    /* Get the view model */
    uploadItemViewModel = ViewModelProviders.of(this).get(UploadItemViewModel.class);

    /* Handle incoming intent content */
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    // FIXME: Google photos URI
    if (type != null) {
        Log.d(TAG, "Receive Type: " + type);
        Uri fileUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
        Log.d(TAG, "\nURI: " + fileUri);
        if (Intent.ACTION_SEND.equals(action) && fileUri != null) {
            handleExplicitFileShare(intent);
        }
    }
    linkTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Copy the content of the link text to Clipboard
            ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clipData = ClipData.newPlainText("link", linkTextView.getText());
            if (clipboardManager != null) {
                clipboardManager.setPrimaryClip(clipData);
                Toast.makeText(MainActivity.this, getString(R.string.link_copy), Toast.LENGTH_SHORT).show();
            }
        }
    });
}
 
开发者ID:rumaan,项目名称:file.io-app,代码行数:39,代码来源:MainActivity.java

示例8: getTextFromAnotherApp

import android.content.Intent; //导入方法依赖的package包/类
@Nullable
private String getTextFromAnotherApp() {
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (type.equals("text/plain")) {
            String text = intent.getStringExtra(Intent.EXTRA_TEXT);
            FirebaseAnalytics.getInstance(this).logEvent("open_from_another_app", new Bundle());
            return text;
        }
    }
    return null;
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:16,代码来源:MainActivity.java

示例9: handleIntent

import android.content.Intent; //导入方法依赖的package包/类
void handleIntent(){
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("text/plain".equals(type)) {
            String youtubeUrlString = intent.getStringExtra(Intent.EXTRA_TEXT);
            String videoId = extractIdFromUrl(youtubeUrlString);
            if (youtubeUrlString != null) {
                download(checkBaseUrl+videoId);
            }
        }
    }
}
 
开发者ID:bornabesic,项目名称:yt-mp3-downloader-android,代码行数:16,代码来源:MainActivity.java

示例10: handleIntent

import android.content.Intent; //导入方法依赖的package包/类
private void handleIntent() {
        Intent intent = getIntent();
        String action = intent.getAction();
        String type = intent.getType();
        if (intent == null) {
            return;
        }
        if (type == null) {
            return;
        }
        //getStringExtra() may return null
        if (Intent.ACTION_SEND.equals(action) && type.equals("text/plain")) {
            mTextToProcess = intent.getStringExtra(Intent.EXTRA_TEXT);
            mTargetWord = intent.getStringExtra(Constant.INTENT_ANKIHELPER_TARGET_WORD);
            mUrl = intent.getStringExtra(Constant.INTENT_ANKIHELPER_TARGET_URL);
            //mFbReaderBookmarkId = intent.getStringExtra(Constant.INTENT_ANKIHELPER_FBREADER_BOOKMARK_ID);
            String noteEditedByUser = intent.getStringExtra(Constant.INTENT_ANKIHELPER_NOTE);
            if(noteEditedByUser != null){
                mNoteEditedByUser = noteEditedByUser;
            }
            String updateId = intent.getStringExtra(Constant.INTENT_ANKIHELPER_NOTE_ID);
            mUpdateAction = intent.getStringExtra(Constant.INTENT_ANKIHELPER_UPDATE_ACTION);
            if(updateId != null && !updateId.isEmpty())
            {
                    try{
                        mUpdateNoteId = Long.parseLong(updateId);
                    }
                    catch(Exception e){

                    }
        }
}
        if (Intent.ACTION_PROCESS_TEXT.equals(action) && type.equals("text/plain")) {
                mTextToProcess = intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT);
                }
                if (mTextToProcess == null) {
            return;
        }
        populateWordSelectBox();
    }
 
开发者ID:mmjang,项目名称:ankihelper,代码行数:41,代码来源:PopupActivity.java

示例11: onCreate

import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get intent, action and MIME type
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("text/plain".equals(type)) {
            handleSendText(intent); // Handle text being sent

        }
    }
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:16,代码来源:AddFeedFromURL.java

示例12: realStartActivityLocked

import android.content.Intent; //导入方法依赖的package包/类
private void realStartActivityLocked(IBinder resultTo, Intent intent, String resultWho, int requestCode,
                                     Bundle options) {
    Class<?>[] types = mirror.android.app.IActivityManager.startActivity.paramList();
    Object[] args = new Object[types.length];
    if (types[0] == IApplicationThread.TYPE) {
        args[0] = ActivityThread.getApplicationThread.call(VirtualCore.mainThread());
    }
    int intentIndex = ArrayUtils.protoIndexOf(types, Intent.class);
    int resultToIndex = ArrayUtils.protoIndexOf(types, IBinder.class, 2);
    int optionsIndex = ArrayUtils.protoIndexOf(types, Bundle.class);
    int resolvedTypeIndex = intentIndex + 1;
    int resultWhoIndex = resultToIndex + 1;
    int requestCodeIndex = resultToIndex + 2;

    args[intentIndex] = intent;
    args[resultToIndex] = resultTo;
    args[resultWhoIndex] = resultWho;
    args[requestCodeIndex] = requestCode;
    if (optionsIndex != -1) {
        args[optionsIndex] = options;
    }
    args[resolvedTypeIndex] = intent.getType();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        args[intentIndex - 1] = VirtualCore.get().getHostPkg();
    }
    ClassUtils.fixArgs(types, args);

    mirror.android.app.IActivityManager.startActivity.call(ActivityManagerNative.getDefault.call(),
            (Object[]) args);
}
 
开发者ID:codehz,项目名称:container,代码行数:31,代码来源:ActivityStack.java

示例13: onStartCommand

import android.content.Intent; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent,int flags, int startID){
    int ret = super.onStartCommand(intent,flags, startID);
    Log.d(TAG,"onStartCommand");
    mIntent = intent;
    //save type because can be lost in PlayerService with setData.
    mType = intent.getType();
    startVideoCast(false);
    return ret;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:11,代码来源:CastService.java

示例14: buildDefaultState

import android.content.Intent; //导入方法依赖的package包/类
private void buildDefaultState() {
    mState = new State();

    final Intent intent = getIntent();
    final String action = intent.getAction();
    if (IntentUtils.ACTION_OPEN_DOCUMENT.equals(action)) {
        mState.action = ACTION_OPEN;
    } else if (IntentUtils.ACTION_CREATE_DOCUMENT.equals(action)) {
        mState.action = ACTION_CREATE;
    } else if (IntentUtils.ACTION_GET_CONTENT.equals(action)) {
        mState.action = ACTION_GET_CONTENT;
    } else if (IntentUtils.ACTION_OPEN_DOCUMENT_TREE.equals(action)) {
        mState.action = ACTION_OPEN_TREE;
    } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) {
        //mState.action = ACTION_MANAGE;
        mState.action = ACTION_BROWSE;
    } else{
        mState.action = ACTION_BROWSE;
    }

    if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
        mState.allowMultiple = intent.getBooleanExtra(IntentUtils.EXTRA_ALLOW_MULTIPLE, false);
    }
    
    if (mState.action == ACTION_GET_CONTENT || mState.action == ACTION_BROWSE) {
        mState.acceptMimes = new String[] { "*/*" };
        mState.allowMultiple = true;
    }
    else if (intent.hasExtra(IntentUtils.EXTRA_MIME_TYPES)) {
        mState.acceptMimes = intent.getStringArrayExtra(IntentUtils.EXTRA_MIME_TYPES);
    } else {
        mState.acceptMimes = new String[] { intent.getType() };
    }

    mState.localOnly = intent.getBooleanExtra(IntentUtils.EXTRA_LOCAL_ONLY, true);
    mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED	, false);
    mState.showAdvanced = mState.forceAdvanced
            | SettingsActivity.getDisplayAdvancedDevices(this);
    
    mState.rootMode = SettingsActivity.getRootMode(this);
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:42,代码来源:DocumentsActivity.java

示例15: onCreate

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setRetainInstance(true);
    setHasOptionsMenu(true);

    bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
    backgroundThread.start();
    backgroundHandler = new Handler(backgroundThread.getLooper());

    if (savedInstanceState != null) {
        restoreInstanceState(savedInstanceState);
    } else {
        final Intent intent = activity.getIntent();
        final String action = intent.getAction();
        final Uri intentUri = intent.getData();
        final String scheme = intentUri != null ? intentUri.getScheme() : null;
        final String mimeType = intent.getType();

        if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))
                && intentUri != null && "bitcoin".equals(scheme)) {
            initStateFromBitcoinUri(intentUri);
        } else if ((NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))
                && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) {
            final NdefMessage ndefMessage = (NdefMessage) intent
                    .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0];
            final byte[] ndefMessagePayload = Nfc.extractMimePayload(PaymentProtocol.MIMETYPE_PAYMENTREQUEST,
                    ndefMessage);
            initStateFromPaymentRequest(mimeType, ndefMessagePayload);
        } else if ((Intent.ACTION_VIEW.equals(action))
                && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) {
            final byte[] paymentRequest = BitcoinIntegration.paymentRequestFromIntent(intent);

            if (intentUri != null)
                initStateFromIntentUri(mimeType, intentUri);
            else if (paymentRequest != null)
                initStateFromPaymentRequest(mimeType, paymentRequest);
            else
                throw new IllegalArgumentException();
        } else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT)) {
            initStateFromIntentExtras(intent.getExtras());
        } else {
            updateStateFrom(PaymentIntent.blank());
        }
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:50,代码来源:SendCoinsFragment.java


注:本文中的android.content.Intent.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。