Example usage for android.net Uri parse

List of usage examples for android.net Uri parse

Introduction

In this page you can find the example usage for android.net Uri parse.

Prototype

public static Uri parse(String uriString) 

Source Link

Document

Creates a Uri which parses the given encoded URI string.

Usage

From source file:Main.java

public static Uri resolveToUri(String baseUri, String referenceUri) {
    return Uri.parse(resolve(baseUri, referenceUri));
}

From source file:Main.java

public static final void openGPS(Context context) {
    Intent GPSIntent = new Intent();
    GPSIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
    GPSIntent.addCategory("android.intent.category.ALTERNATIVE");
    GPSIntent.setData(Uri.parse("custom:3"));
    try {//from   w  ww.  ja  va 2  s . co  m
        PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send();
    } catch (PendingIntent.CanceledException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void openGPS(Context context) {

    Intent GPSIntent = new Intent();

    GPSIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");

    GPSIntent.addCategory("android.intent.category.ALTERNATIVE");
    GPSIntent.setData(Uri.parse("custom:3"));

    try {//from w w w .ja va 2  s .  c o m
        PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send();
    } catch (PendingIntent.CanceledException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void installApk(Context context, String apkUrl) {
    File file = new File(apkUrl);
    if (!file.exists())
        return;/*  www  .  j ava 2 s .  c  o  m*/
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse(apkUrl), type);
    context.startActivity(intent);
}

From source file:Main.java

public static void openAppSettings(Context context) {
    Intent myAppSettings = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
            Uri.parse("package:" + context.getPackageName()));
    myAppSettings.addCategory(Intent.CATEGORY_DEFAULT);
    myAppSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(myAppSettings);
}

From source file:Main.java

public static ArrayList<String> findSmsByAddress(Context context, String address) {
    ArrayList<String> list = new ArrayList<String>();
    try {//from www  .j  av  a2  s.  c  o  m
        Cursor c = context.getContentResolver().query(Uri.parse("content://sms/inbox"),
                new String[] { "_id", "address" }, "address = ?", new String[] { address }, null);
        if (!c.moveToFirst() || c.getCount() == 0) {
            LOGI("there are no more messages");
            c.close();
            return list;
        }
        do {
            list.add(c.getString(0));
        } while (c.moveToNext());
        c.close();
    } catch (Exception e) {
        LOGE("findSmsByAddress: " + e.getMessage());
    }

    return list;
}

From source file:Main.java

public static void startSettingIntent(Context context, Intent intent) {
    try {//from   www.  ja v a2 s.  com
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    } catch (Exception e) {
        intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.setData(Uri.parse("package:" + context.getPackageName()));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }
}

From source file:Main.java

public static String getHost(String url) {
    if (url == null || url.length() == 0) {
        return "<Unknown>";
    }/*from ww  w  .  j  a  v  a2  s .co m*/

    return Uri.parse(url).getHost();
}

From source file:Main.java

private static void shareAct(Activity act, String fileName, String text) {

    Uri uri = null;/*from  w  w  w .  j  a  va2s  . c  o m*/

    try {
        FileInputStream input = act.openFileInput(fileName);
        Bitmap bitmap = BitmapFactory.decodeStream(input);
        uri = Uri.parse(MediaStore.Images.Media.insertImage(act.getContentResolver(), bitmap, null, null));
        input.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    shareIntent.setType("image/jpeg");
    act.startActivity(Intent.createChooser(shareIntent, act.getTitle()));
}

From source file:Main.java

public static void playRingtone(Context context) {
    //       Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    //        if(alert == null){
    //            alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
    //        }/*from w w  w .  j  a  v a  2s.c  o  m*/
    //       Ringtone r = RingtoneManager.getRingtone(context, alert);
    //       r.play();

    Uri path = Uri.parse("android.resource://" + context.getPackageName() + "/raw/waterdrop4");
    //       RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE,path);
    RingtoneManager.getRingtone(context, path).play();
}