Java Code Examples for android.content.Intent#getType()

The following examples show how to use android.content.Intent#getType() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ShaderEditor   File: AddUniformActivity.java    License: MIT License 6 votes vote down vote up
private void startActivityForIntent(Intent intent) {
	if (intent == null) {
		return;
	}

	String type;
	if (!Intent.ACTION_SEND.equals(intent.getAction()) ||
			(type = intent.getType()) == null ||
			!type.startsWith("image/")) {
		return;
	}

	Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
	if (imageUri == null) {
		return;
	}

	startActivity(CropImageActivity.getIntentForImage(this, imageUri));
}
 
Example 2
@Override
public void onResume() {
    super.onResume();

    CalculatorSetting preferences = new CalculatorSetting(this);
    String math = preferences.getString(CalculatorSetting.INPUT_MATH);
    mInputDisplay.setText(math);

    ///receive data from another application
    Intent intent = new Intent();
    String action = intent.getAction();
    String type = intent.getType();
    //process data
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("text/plain".equals(type)) {
            mInputDisplay.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
        }
    }
    if (mInputDisplay != null) mInputDisplay.requestFocus();
}
 
Example 3
Source Project: physical-web   File: BroadcastActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    Intent intent = getIntent();
    String type = intent.getType();
    String text = intent.getStringExtra(Intent.EXTRA_TEXT);
    if (type.equals("text/plain")) {
        if (Build.VERSION.SDK_INT < 21) {
            Toast.makeText(this, getString(R.string.ble_os_error),
                Toast.LENGTH_LONG).show();
            return;
        }
        if (!checkIfBluetoothIsEnabled()) {
            Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableBtIntent, ENABLE_BLUETOOTH_REQUEST_ID);
        } else {
            checkBleAndStart();
        }
    } else if (type.startsWith("image/") || type.startsWith("text/html") ||
        type.startsWith("video") || type.startsWith("audio")) {
        Log.d(TAG, type);
        Uri fileUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
        Log.d(TAG, fileUri.toString());
        startFileBroadcastService(fileUri.toString(), type);
    }
}
 
Example 4
private 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 sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
        	    if (sharedText != null) {
        	        // Update UI to reflect text being shared
        	    	
     			TextView tvStatus = ((TextView) findViewById(R.id.edit_text_out));
     			tvStatus.append(sharedText);
        	    	
        	    }
        }
    }
    
}
 
Example 5
Source Project: dbclf   File: CameraActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(null);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_camera);

    setupButtons();
    setupPieChart();
    initClassifier();

    // Get intent, action and MIME type
    final Intent intent = getIntent();
    final String action = intent.getAction();
    final String type = intent.getType();

    // Handle single image being sent from other application
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            if (inferenceTask != null)
                inferenceTask.cancel(true);

            handleSendImage(intent);
        }
    }
}
 
Example 6
/**
 * Takes care of images that are sent to the application when it is already running.
 *
 * @param intent current intent.
 */
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    Log.d(this.getLocalClassName(), "On new intent requested");

    // Code for shared images to this activity
    String action = intent.getAction();
    String type   = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            fetchImage(intent);
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            fetchMultipleImages(intent); // Handle multiple images being sent
        }
    }

}
 
Example 7
Source Project: catnut   File: ComposeTweetActivity.java    License: MIT License 5 votes vote down vote up
private void handleOuterShare() {
	Intent intent = getIntent();
	String action = intent.getAction();
	String mimeType = intent.getType();
	if (!TextUtils.isEmpty(action)) {
		if (!TextUtils.isEmpty(mimeType)) {
			if (mimeType.equals(getString(R.string.mime_text_plain))) {
				mText.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
				setResult(RESULT_OK); // no result return back
			} else if (mimeType.startsWith("image/")) {
				mText.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
				if (mUris == null) {
					initGallery();
					// 不接受binary data,只接受uri
					// 此时不可能会有两个图片滴
					mUris.add((Uri) intent.getExtras().get(Intent.EXTRA_STREAM));
					mAdapter.notifyDataSetChanged();
					setResult(RESULT_OK);
				}
			} else {
				setResult(RESULT_CANCELED);
			}
		} else {
			setResult(RESULT_CANCELED);
		}
	}
}
 
Example 8
Source Project: style-transfer   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 9
private void handleIntent (Intent intent)
{


    if (intent != null)
    {
        Uri data = intent.getData();
        String type = intent.getType();
      if (data != null && Imps.Chats.CONTENT_ITEM_TYPE.equals(type)) {

            long chatId = ContentUris.parseId(data);
            Intent intentChat = new Intent(this, ConversationDetailActivity.class);
            intentChat.putExtra("id", chatId);
            startActivity(intentChat);
        }
        else if (Imps.Contacts.CONTENT_ITEM_TYPE.equals(type))
        {
            long providerId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID,mApp.getDefaultProviderId());
            long accountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID,mApp.getDefaultAccountId());
            String username = intent.getStringExtra(ImServiceConstants.EXTRA_INTENT_FROM_ADDRESS);
            startChat(providerId, accountId, username,  true);
        }
        else if (intent.hasExtra("username"))
        {
            //launch a new chat based on the intent value
            startChat(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(), intent.getStringExtra("username"),  true);
        }

        setIntent(null);
    }
}
 
Example 10
private void onSendFile(Intent intent) {
    if (intent.getType() != null && intent.getType().startsWith("audio/")) {
        File newFile = new File(intent.getData().getPath());
        if (FileUtils.existsInternalFile(this, newFile.getName())) {
            Toast.makeText(this, getString(R.string.error_entry_exists), Toast.LENGTH_LONG).show();
        } else if (!(onFileAdded(new File(intent.getData().getPath())))) {
            Toast.makeText(this, getString(R.string.error_add, intent.getData().getPath()), Toast.LENGTH_LONG).show();
        }
    }
}
 
Example 11
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);
}
 
Example 12
private boolean handleEnqueue(Intent intent, ControlRequestCallback callback) {
    String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID);
    if (sid != null && !sid.equals(mSessionManager.getSessionId())) {
        Log.d(TAG, "handleEnqueue fails because of bad sid="+sid);
        return false;
    }

    Uri uri = intent.getData();
    if (uri == null) {
        Log.d(TAG, "handleEnqueue fails because of bad uri="+uri);
        return false;
    }

    boolean enqueue = intent.getAction().equals(MediaControlIntent.ACTION_ENQUEUE);
    String mime = intent.getType();
    long pos = intent.getLongExtra(MediaControlIntent.EXTRA_ITEM_CONTENT_POSITION, 0);
    Bundle metadata = intent.getBundleExtra(MediaControlIntent.EXTRA_ITEM_METADATA);
    Bundle headers = intent.getBundleExtra(MediaControlIntent.EXTRA_ITEM_HTTP_HEADERS);
    PendingIntent receiver = (PendingIntent)intent.getParcelableExtra(
            MediaControlIntent.EXTRA_ITEM_STATUS_UPDATE_RECEIVER);

    Log.d(TAG, mRouteId + ": Received " + (enqueue?"enqueue":"play") + " request"
            + ", uri=" + uri
            + ", mime=" + mime
            + ", sid=" + sid
            + ", pos=" + pos
            + ", metadata=" + metadata
            + ", headers=" + headers
            + ", receiver=" + receiver);
    PlaylistItem item = mSessionManager.add(uri, mime, receiver);
    if (callback != null) {
        if (item != null) {
            Bundle result = new Bundle();
            result.putString(MediaControlIntent.EXTRA_SESSION_ID, item.getSessionId());
            result.putString(MediaControlIntent.EXTRA_ITEM_ID, item.getItemId());
            result.putBundle(MediaControlIntent.EXTRA_ITEM_STATUS,
                    item.getStatus().asBundle());
            callback.onResult(result);
        } else {
            callback.onError("Failed to open " + uri.toString(), null);
        }
    }
    mEnqueueCount +=1;
    return true;
}
 
Example 13
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
    activity.setSupportActionBar(toolbar);
    if(activity.getSupportActionBar() != null){
        activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        if(activity.isInMultiWindowMode() && activity.findViewById(R.id.spinner_notebook) == null){
            //if the activity resizes in multiwindow mode to phone ui, all views in this fragment will be null becuase they are not displayed, so don't do anything
            Intent returnIntent = new Intent();
            returnIntent.putExtra("selectedNotebookName",givenNotebook);

            ((OnFragmentCallback)activity).fragmentFinished(returnIntent, OnFragmentCallback.ResultCode.NOT_VISIBLE);
            return;
        }
    }

    setHasOptionsMenu(true);

    initTextEditor();

    // Handle Back Navigation :D
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DetailFragment.this.onBackPressed();
        }
    });

    Intent startIntent = activity.getIntent();
    String uid = startUid;
    String notebook = startNotebook;
    String accountEmail = startIntent.getStringExtra(Utils.INTENT_ACCOUNT_EMAIL);
    String rootFolder = startIntent.getStringExtra(Utils.INTENT_ACCOUNT_ROOT_FOLDER);

    String action = startIntent.getAction();

    if (Intent.ACTION_SEND.equals(action)) {
        final String type = startIntent.getType();

        if(type != null && type.startsWith("image")){
            loadImageFromIntent(startIntent);
        }else{
            takeTextFromIntent(startIntent);
        }
    }

    Log.d("onCreate", "accountEmail:" + accountEmail);
    Log.d("onCreate","rootFolder:"+rootFolder);
    Log.d("onCreate","notebook-uid:"+notebook);

    ActiveAccount activeAccount;
    if(accountEmail != null && rootFolder != null){
        activeAccount = activeAccountRepository.switchAccount(accountEmail,rootFolder);
    }else{
        activeAccount = activeAccountRepository.getActiveAccount();
    }

    toolbar.setTitle(Utils.getNameOfActiveAccount(activity, activeAccount.getAccount(), activeAccount.getRootFolder()));

    if(uid != null) {

        //if a note was selected from the "all notes" overview
        final AccountIdentifier accountFromNote = noteRepository.getAccountFromNote(uid);
        if(!activeAccount.getAccount().equals(accountFromNote.getAccount()) || !activeAccount.getRootFolder().equals(accountFromNote.getRootFolder())){
            activeAccount = activeAccountRepository.switchAccount(accountFromNote.getAccount(),accountFromNote.getRootFolder());
        }

        initSpinner();

        notebook = initNote(uid, notebook, activeAccount);
    }else{
        initSpinner();
        isNewNote = true;
    }

    initTags(activeAccount);
    initNotebook(notebook, activeAccount);

    if (savedInstanceState != null && savedInstanceState.getString(EDITOR) != null) {
        /* Restoring saved data into editor */
        String descriptionValue = initImageMap(savedInstanceState.getString(EDITOR));
        setHtml(descriptionValue);
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        activity.findViewById(R.id.action_insert_image).setVisibility(View.GONE);
    }
}
 
Example 14
Source Project: Simpler   File: WBPostActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wb_post);
    ButterKnife.bind(this);

    if ("".equals(BaseConfig.sUid)) {
        // 没有授权用户
        AppToast.showToast("请先登录");
        App.getInstance().finishAllActivities();
        startActivity(WBLoginActivity.newIntent(this));
    }

    //声明LocationClient类
    mLocationClient = new LocationClient(getApplicationContext());
    //注册监听函数
    mLocationClient.registerLocationListener(myListener);
    mLocationClient.setLocOption(BDLocationUtil.getLocationClientOption());

    //设置布局管理器
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mRvPhotos.setLayoutManager(linearLayoutManager);
    mPhotoAdapter = new PostPhotosAdapter(this, postPicClickListener);
    mRvPhotos.setAdapter(mPhotoAdapter);

    sContentBuilder = new StringBuilder();
    mEtContent.requestFocus();
    // 添加文本变化监听器
    mEtContent.addTextChangedListener(new StatusTextWatcher());

    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        mTvTitle.setText("分享给好友");
        if ("text/plain".equals(type)) {
            // 处理发来的文字
            String string = intent.getStringExtra(Intent.EXTRA_TEXT);
            mEtContent.setText(string);
            mEtContent.setSelection(mEtContent.length());
        } else if (type.startsWith("image/")) {
            // 处理发送来的图片
            handleSendImage(intent);
        } else if (type.startsWith("*/*")) {
            // 处理发送来的未知数据
            handleSendUnknown(intent);
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            // 处理发送来的多张图片
            handleSendMultipleImages(intent);
        } else if (type.startsWith("*/*")) {
            // 处理发送来的多个未知数据
            handleSendMultipleUnknown(intent);
        }
    } else {
        String title = intent.getStringExtra(INTENT_TITLE);
        mOldDraft = intent.getParcelableExtra(INTENT_DRAFT);
        if (mOldDraft != null) {
            init();     // 初始化发博器
        }
        if (!TextUtils.isEmpty(title)) {
            String text = intent.getStringExtra(INTENT_TEXT);
            String hint = intent.getStringExtra(INTENT_HINT);
            mTvTitle.setText(title);
            mEtContent.setHint(hint);
            mEtContent.setText(text);
            mEtContent.setSelection(mEtContent.length());
        }
    }
    // 打开输入法软键盘
    InputMethodUtils.openSoftKeyboard(this, mEtContent);
}
 
Example 15
Source Project: intra42   File: UserActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //handle just logged users.
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("text/plain".equals(type)) {
            login = handleSendText(intent); // Handle text being sent
        }
    } else if (Intent.ACTION_VIEW.equals(action)) {
        Uri uri;
        if ((uri = intent.getData()) != null && uri.getHost().equals("profile.intra.42.fr")) {
            List<String> tmp = intent.getData().getPathSegments();
            if (tmp.size() == 2)
                login = tmp.get(1);
        }
    } else {
        if (intent.hasExtra(INTENT_USER_FULL)) {
            user = ServiceGenerator.getGson().fromJson(intent.getStringExtra(INTENT_USER_FULL), Users.class);
            if (user != null)
                login = user.login;
        } else if (intent.hasExtra(INTENT_USER_LTE)) {
            login = ServiceGenerator.getGson().fromJson(intent.getStringExtra(INTENT_USER_LTE), UsersLTE.class).login;
        } else if (intent.hasExtra(INTENT_LOGIN))
            login = intent.getStringExtra(INTENT_LOGIN).toLowerCase();
    }

    user = (Users) getLastCustomNonConfigurationInstance();
    if (user != null)
        login = user.login;

    registerGetDataOnOtherThread(this);
    registerGetDataOnMainTread(this);

    super.setActionBarToggle(ActionBarToggle.ARROW);
    super.setSelectedMenu(Navigation.MENU_SELECTED_USERS);

    ThemeHelper.setActionBar(actionBar, AppSettings.Theme.EnumTheme.DEFAULT);
    if (user == null && login == null)
        finish();

    super.onCreateFinished();
}
 
Example 16
private void doOnCreate ()
{
    Intent intent = getIntent();
    if (Intent.ACTION_INSERT.equals(intent.getAction())) {
        if (!resolveInsertIntent(intent)) {
            finish();
            return;
        }
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {

        Uri streamUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
        String mimeType = intent.getType();
        String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);

        if (streamUri != null)
            openOtrInBand(streamUri, mimeType);
        else if (intent.getData() != null)
            openOtrInBand(intent.getData(), mimeType);
        else if (sharedText != null)
        {
            //do nothing for now :(
            mSendText = sharedText;

            startContactPicker();

        }
        else
            finish();

    } else if (Intent.ACTION_SENDTO.equals(intent.getAction())|| Intent.ACTION_VIEW.equals(intent.getAction())) {
        if (!resolveIntent(intent)) {
            finish();
            return;
        }

        if (TextUtils.isEmpty(mToAddress)) {
            LogCleaner.warn(ImApp.LOG_TAG, "<ImUrlActivity>Invalid to address");
          //  finish();
            return;
        }

        ImApp mApp = (ImApp)getApplication();

        if (mApp.serviceConnected())
            handleIntent();
        else
        {
            mApp.callWhenServiceConnected(new Handler(), new Runnable() {
                public void run() {

                   handleIntent();
                }
            });
            Toast.makeText(ImUrlActivity.this, R.string.starting_the_chatsecure_service_, Toast.LENGTH_LONG).show();

        }
    } else {
        finish();
    }
}
 
Example 17
@Override
public void onStart() {
    Intent intent = getActivity().getIntent();
    String action = intent.getAction();
    if (Intent.ACTION_SEND.equals(action)) {
        String type = intent.getType();
        if ("text/x-vcard".equals(type)) {
            isShare = true;
            Uri contactUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            ContentResolver cr;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
                cr = this.getContext().getContentResolver();
            else cr = getActivity().getContentResolver();

            String data = "";
            try {
                InputStream stream = cr.openInputStream(contactUri);
                StringBuffer fileContent = new StringBuffer("");
                int ch;
                while ((ch = stream.read()) != -1)
                    fileContent.append((char) ch);
                stream.close();
                data = new String(fileContent);

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

            for (String line : data.split("\n")) {
                line = line.trim();
                //todo: support other phone numbers from vcard
                if (line.startsWith("TEL;CELL:")) {
                    number = line.substring(9);
                    mPhoneInput.setPhoneNumber(number);
                }
            }
        }
    } else if (Intent.ACTION_DIAL.equals(action)) {
        number = intent.getData().toString().substring(3);
        Log.d(MainFragment.class.getName(), "onStart: number==" + number);
        mPhoneInput.setPhoneNumber(number);
    }
    super.onStart();
}
 
Example 18
Source Project: PluginLoader   File: PluginIntentFilter.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Test whether this filter matches the given <var>intent</var>.
 *
 * @param intent The Intent to compare against.
 * @param resolve If true, the intent's type will be resolved by calling
 *                Intent.resolveType(); otherwise a simple match against
 *                Intent.type will be performed.
 * @param logTag Tag to use in debugging messages.
 *
 * @return Returns either a valid match constant (a combination of
 * {@link #MATCH_CATEGORY_MASK} and {@link #MATCH_ADJUSTMENT_MASK}),
 * or one of the error codes {@link #NO_MATCH_TYPE} if the type didn't match,
 * {@link #NO_MATCH_DATA} if the scheme/path didn't match,
 * {@link #NO_MATCH_ACTION if the action didn't match, or
 * {@link #NO_MATCH_CATEGORY} if one or more categories didn't match.
 *
 * @return How well the filter matches.  Negative if it doesn't match,
 *         zero or positive positive value if it does with a higher
 *         value representing a better match.
 *
 * @see #match(String, String, String, android.net.Uri , Set, String)
 */
public final int match(ContentResolver resolver, Intent intent,
                       boolean resolve, String logTag) {
    String type = resolve ? intent.resolveType(resolver) : intent.getType();
    return match(intent.getAction(), type, intent.getScheme(),
            intent.getData(), intent.getCategories());
}
 
Example 19
/**
 * Test whether this filter matches the given <var>intent</var>.
 *
 * @param intent The Intent to compare against.
 * @param resolve If true, the intent's type will be resolved by calling
 *                Intent.resolveType(); otherwise a simple match against
 *                Intent.type will be performed.
 * @param logTag Tag to use in debugging messages.
 *
 * @return Returns either a valid match constant (a combination of
 * {@link #MATCH_CATEGORY_MASK} and {@link #MATCH_ADJUSTMENT_MASK}),
 * or one of the error codes {@link #NO_MATCH_TYPE} if the type didn't match,
 * {@link #NO_MATCH_DATA} if the scheme/path didn't match,
 * {@link #NO_MATCH_ACTION if the action didn't match, or
 * {@link #NO_MATCH_CATEGORY} if one or more categories didn't match.
 *
 * @return How well the filter matches.  Negative if it doesn't match,
 *         zero or positive positive value if it does with a higher
 *         value representing a better match.
 *
 * @see #match(String, String, String, android.net.Uri , Set, String)
 */
public final int match(ContentResolver resolver, Intent intent,
        boolean resolve, String logTag) {
    String type = resolve ? intent.resolveType(resolver) : intent.getType();
    return match(intent.getAction(), type, intent.getScheme(),
                 intent.getData(), intent.getCategories());
}
 
Example 20
@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    runOnUiThread(new Runnable() {
        @Override
        public void run() {

            contextThemeWrapper = new ContextThemeWrapper(getBaseContext(), MediaBrowser.this.getTheme());

            Preferences.applyTheme(contextThemeWrapper, getBaseContext());

            ImmersiveMode.On(MediaBrowser.this);

        }
    });

    setContentView(R.layout.media_pager);

    Intent intent = getIntent();
    String action = intent.getAction();
    type = intent.getType();

    if (Intent.ACTION_VIEW.equals(action) && type != null) {

        if (type.startsWith("image/") || type.startsWith("video/")) {

            Uri imageUri = intent.getData();

            url = convertMediaUriToPath(imageUri);

        }

    }

    runOnUiThread(new Runnable() {
        @Override
        public void run() {

            initViews();

            initMediaView();

        }
    });

}