How to enqueue music to default android music player via app? -
i new android app development, have knowledge of programming in java , in general. trying write app android can enqueue music files default music player in android (like google play music). app decides song play when, don't want write full-blown music player app. want feed existing player app new music.
i looking "inter-app" communication (perhaps using intent?) through can feed content music player , control player itself.
i not sure if such facility exist in android, other alternative suggestions welcome. also, please let me know if didn't explain problem properly.
intents powerful feature of android there isn't direct analog in java. want use mechanism known implicit intent. normally, when launch 1 activity another, create intent , specify activity start. implicit intent, provide action (intent.action_view) , data (a uri pointing music file). using implicit intent, have piece of data handled without knowing in advance activity handling.
when pass intent startactivity(), os attempt resolve data in best way possible, typically popping list of apps can possibly handle data. user selects appropriate app , app handles intent, playing music file. app registers service capable of potentially handling data show in list. after passing intent, activity go background, , app handling intent come foreground.
once user has selected app handle intent activity, app used handle kind of intent activity until delete own app's data.
take @ official doc started , ask new question when have more specific problem you're trying address.
here's code sample demonstrates simple implicit intent example, url opened without knowing browser open it:
package com.marsatomic.intentimplicitdemo; import android.os.bundle; import android.app.activity; import android.content.intent; import android.net.uri; import android.view.menu; import android.view.view; import android.widget.button; public class mainactivity extends activity { public final static uri uri = uri.parse("http://www.marsatomic.com"); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button buttonconnect = (button)findviewbyid(r.id.button_connect); buttonconnect.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { intent = new intent(intent.action_view, uri); startactivity(i); } }); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } }
Comments
Post a Comment