Changed notification to always shouw route fragment.

This commit is contained in:
Felix Ableitner 2013-12-10 20:28:40 +01:00
parent 8a08fb00ec
commit cc2fda0166
3 changed files with 15 additions and 3 deletions

View file

@ -32,6 +32,7 @@ import java.util.List;
import org.teleal.cling.support.model.item.Item;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@ -100,6 +101,7 @@ public class MainActivity extends ActionBarActivity {
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
onNewIntent(getIntent());
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
@ -195,6 +197,15 @@ public class MainActivity extends ActionBarActivity {
}
}
/**
* Displays the RouteFragment immediately (instead of ServerFragment).
*/
@Override
protected void onNewIntent(Intent intent) {
if (intent.getAction().equals("showRouteFragment"))
mViewPager.setCurrentItem(1);
}
/**
* Saves fragments.
*/

View file

@ -485,7 +485,6 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
if (mListView.getAdapter() == mPlaylistAdapter)
enableTrackHighlight();
}
}

View file

@ -131,9 +131,11 @@ public class MediaRouterPlayService extends Service {
artist = track.getArtists()[0].getName();
}
}
Intent intent = new Intent(MediaRouterPlayService.this, MainActivity.class);
intent.setAction("showRouteFragment");
Notification notification = new NotificationCompat.Builder(MediaRouterPlayService.this)
.setContentIntent(PendingIntent.getActivity(MediaRouterPlayService.this, 0,
new Intent(MediaRouterPlayService.this, MainActivity.class), 0))
intent, 0))
.setContentTitle(title)
.setContentText(artist)
.setLargeIcon(result)