Android tutorial video summary

Source: Internet
Author: User

Android tutorial video summary:

(1) Part 1: quickly learn about Android videos in 8 days.

(2) The second tutorial on Android Development

(3) sundy's <Android introduction> <Android advanced applications> <Android development video tutorial>

(4) course series of "android development starts from scratch"

(5) Li Xinghua teaches you how to develop android

(6) Android development video tutorial of Mars

Http://url.cn/IEYPzR

Http://t3.qpic.cn/mblogpic/9088bb506dba8eb45c58/2000 http://t.qq.com/p/t/180962016212776

// Musiccontrol. Java

Package com. Android. Internal. Policy. impl;

Import java. Io. filedescriptor;
Import java. Io. filenotfoundexception;
Import java. util. formatter;
Import java. util. locale;
Import Android. util. log;
Import com. Android. Internal. R;
Import com. Android. Music. imediaplaybackservice;
Import Android. content. componentname;
Import Android. content. contenturis;
Import Android. content. context;
Import Android. content. intent;
Import Android. content. serviceconnection;
Import Android. Graphics. Bitmap;
Import Android. Graphics. bitmapfactory;
Import Android. Graphics. matrix;
Import Android. widget .*;
Import android.net. Uri;
Import Android. OS. Handler;
Import Android. OS. ibinder;
Import Android. OS. message;
Import Android. OS. parcelfiledescriptor;
Import Android. OS. RemoteException;
Import Android. provider. mediastore;
Import Android. View. view;
Import Android. widget. imagebutton;
Import Android. widget. linearlayout;
Import Android. widget. progressbar;
Import Android. widget. textview;

Public class musiccontrol implements view. onclicklistener, serviceconnection {
Private view musiccontrolview;
Private relativelayout mmusicwidget;
Private imagebutton prevsong;
Private imagebutton pauseorplay;
Private imagebutton nextsong;
Private textview artistname;
Private textview songname;
Private textview trackname;
Private textview mdate;
Private imediaplaybackservice mservice;
Private context mcontext;
Private string tag = "musiccontrol ";

Private Final Static int refresh = 0;
Handler mhandler = new handler (){

@ Override
Public void handlemessage (Message MSG ){
Switch (msg. What ){
Case Refresh:
Try {
If (mservice! = NULL ){
Artistname. settext (mservice. getartistname ());
Songname. settext (mservice. gettrackname ());
Trackname. settext (mservice. gettrackname ());
If (mservice. isplaying ()){
Pauseorplay. setimageresource (R. drawable. iphone_stop );
} Else {
Pauseorplay. setimageresource (R. drawable. iphone_play );
}
}
} Catch (RemoteException e ){
E. printstacktrace ();
}
Mhandler. removemessages (refresh );
Mhandler. sendemptymessagedelayed (refresh, 1000 );
Break;

Default:
Break;
}
}

};

Public musiccontrol (context, view musicview ){
Log. D (TAG, "musiccontrol Contruct ");
Mcontext = context;
Musiccontrolview = musicview;
Mcontext. bindservice (new intent ("com. Android. Music. mediaplaybackservice"), this, context. bind_auto_create );
 
Prevsong = (imagebutton) musiccontrolview. findviewbyid (R. Id. musiccontrolprevious );
Pauseorplay = (imagebutton) musiccontrolview. findviewbyid (R. Id. musiccontrolplayorpause );
Nextsong = (imagebutton) musiccontrolview. findviewbyid (R. Id. musiccontrolnext );

Artistname = (textview) musiccontrolview. findviewbyid (R. Id. Artist );
Songname = (textview) musiccontrolview. findviewbyid (R. Id. song_name );
Trackname = (textview) musiccontrolview. findviewbyid (R. Id. track_name );

Prevsong. setonclicklistener (this );
Pauseorplay. setonclicklistener (this );
Nextsong. setonclicklistener (this );
}
 
Public void startrefresh (){
Mhandler. removemessages (refresh );
Mhandler. sendemptymessage (refresh );
}
Public void stoprefresh (){
Mhandler. removemessages (refresh );
}
Public String getmusictrack () throws RemoteException {
Return mservice. gettrackname ();
}

@ Override
Public void onclick (view v ){
If (V = prevsong ){
Try {
Log. D (TAG, "musiccontrol onclick mservice:" + mservice );
If (mservice! = NULL ){
Mservice. Prev ();
}
} Catch (RemoteException e ){
E. printstacktrace ();
}
} Else if (V = pauseorplay ){
Try {
Log. D (TAG, "musiccontrol onclick mservice:" + mservice );
If (mservice! = NULL ){
If (mservice. isplaying ()){
Mservice. Pause ();
Pauseorplay. setimageresource (R. drawable. iphone_play );
} Else {
Mservice. Play ();
Pauseorplay. setimageresource (R. drawable. iphone_stop );
}
}

} Catch (RemoteException e ){
E. printstacktrace ();
}
} Else if (V = nextsong ){
Log. D (TAG, "musiccontrol onclick mservice:" + mservice );
Try {
If (mservice! = NULL ){
Mservice. Next ();
}

} Catch (RemoteException e ){
E. printstacktrace ();
}
}
}

@ Override
Public void onserviceconnected (componentname name, ibinder Service ){
Log. D (TAG, "musiccontrol onserviceconnected ");
Mservice = imediaplaybackservice. stub. asinterface (service );
}

@ Override
Public void onservicedisconnected (componentname arg0 ){
Mservice = NULL;
}
 
Public Boolean ismusicplay (){
Log. D (TAG, "musiccontrol ismusicplay mservice:" + mservice );
Boolean isplay = false;
If (mservice! = NULL ){
Try {
Isplay = mservice. isplaying ();
} Catch (RemoteException e ){
Log. D (TAG, "musiccontrol ismusicplay RemoteException ");
Isplay = false;
E. printstacktrace ();
}
}
Return isplay;
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.