use of android.net.Uri in project Rutgers-Course-Tracker by tevjef.
the class TrackedSectionsFragment method launchMarket.
private void launchMarket() {
final Uri uri = Uri.parse("market://details?id=" + getParentActivity().getApplicationContext().getPackageName());
final Intent rateAppIntent = new Intent(Intent.ACTION_VIEW, uri);
if (getParentActivity().getPackageManager().queryIntentActivities(rateAppIntent, 0).size() > 0) {
startActivity(rateAppIntent);
}
}
use of android.net.Uri in project Shuttle by timusus.
the class VideoCastManager method updateMediaSessionMetadata.
/*
* On ICS and JB, lock screen metadata is one liner: Title - Album Artist - Album. On KitKat, it
* has two lines: Title , Album Artist - Album
*/
private void updateMediaSessionMetadata() {
if ((mMediaSessionCompat == null) || !isFeatureEnabled(CastConfiguration.FEATURE_LOCKSCREEN)) {
return;
}
try {
MediaInfo info = getRemoteMediaInformation();
if (info == null) {
return;
}
final MediaMetadata mm = info.getMetadata();
MediaMetadataCompat currentMetadata = mMediaSessionCompat.getController().getMetadata();
MediaMetadataCompat.Builder newBuilder = currentMetadata == null ? new MediaMetadataCompat.Builder() : new MediaMetadataCompat.Builder(currentMetadata);
MediaMetadataCompat metadata = newBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, mm.getString(MediaMetadata.KEY_TITLE)).putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, mContext.getResources().getString(R.string.ccl_casting_to_device, getDeviceName())).putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, mm.getString(MediaMetadata.KEY_TITLE)).putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, mm.getString(MediaMetadata.KEY_SUBTITLE)).putLong(MediaMetadataCompat.METADATA_KEY_DURATION, info.getStreamDuration()).build();
mMediaSessionCompat.setMetadata(metadata);
Uri iconUri = mm.hasImages() ? mm.getImages().get(0).getUrl() : null;
if (iconUri == null) {
Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.album_art_placeholder);
mMediaSessionCompat.setMetadata(newBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, bm).build());
} else {
if (mMediaSessionIconFetchTask != null) {
mMediaSessionIconFetchTask.cancel(true);
}
mMediaSessionIconFetchTask = new FetchBitmapTask() {
@Override
protected void onPostExecute(Bitmap bitmap) {
if (bitmap != null && mMediaSessionCompat != null) {
MediaMetadataCompat currentMetadata = mMediaSessionCompat.getController().getMetadata();
MediaMetadataCompat.Builder newBuilder = currentMetadata == null ? new MediaMetadataCompat.Builder() : new MediaMetadataCompat.Builder(currentMetadata);
mMediaSessionCompat.setMetadata(newBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, bitmap).build());
}
mMediaSessionIconFetchTask = null;
}
};
mMediaSessionIconFetchTask.execute(iconUri);
}
} catch (NotFoundException e) {
LOGE(TAG, "Failed to update Media Session due to resource not found", e);
} catch (TransientNetworkDisconnectionException | NoConnectionException e) {
LOGE(TAG, "Failed to update Media Session due to network issues", e);
}
}
use of android.net.Uri in project jpHolo by teusink.
the class StartActivityUri method onCreate.
@SuppressLint("NewApi")
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
WebView.setWebContentsDebuggingEnabled(true);
}
}
final SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
final SharedPreferences.Editor editor = settings.edit();
final Uri data = getIntent().getData();
// final String scheme = data.getScheme(); // Not needed
// final String host = data.getHost(); // Not needed
// final String path = data.getPath(); // Not needed
final String message = data.getQueryParameter("message");
editor.putString("UriMessage", message);
editor.commit();
if (checkScreenSize().equals("large") || checkScreenSize().equals("xlarge")) {
initiateApp("tablet");
} else {
initiateApp("smartphone");
}
}
use of android.net.Uri in project Shuttle by timusus.
the class PlaylistUtils method clearPlaylist.
/**
* Method clearPlaylist.
*
* @param context Context
* @param playlistId int
*/
public static void clearPlaylist(Context context, int playlistId) {
final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId);
context.getContentResolver().delete(uri, null, null);
}
use of android.net.Uri in project Shuttle by timusus.
the class PlaylistUtils method removeFromFavorites.
public static void removeFromFavorites(Context context) {
Song song = MusicUtils.getSong();
if (song == null) {
return;
}
Observable.fromCallable(() -> {
Playlist favoritesPlaylist = Playlist.favoritesPlaylist();
if (favoritesPlaylist.id >= 0) {
final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", favoritesPlaylist.id);
return context.getContentResolver().delete(uri, MediaStore.Audio.Playlists.Members.AUDIO_ID + "=" + song.id, null);
}
return 0;
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(numTracksAdded -> {
if (numTracksAdded > 0) {
Toast.makeText(context, context.getResources().getString(R.string.song_removed_from_favourites, song.name), Toast.LENGTH_SHORT).show();
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(MusicService.InternalIntents.FAVORITE_CHANGED));
}
});
}
Aggregations