Hi,,, No body is there aa to save me from this issue :(
On Tue, Nov 4, 2008 at 11:44 AM, yasmin afrose <[EMAIL PROTECTED]>wrote: > Hi All, > > Greetings!!! > > I've played .mp3 songs using MediaPlayer in Android 1.0. > > *My code was*: > > 1:* PrankActivity.java* > ------------------------------ > > package com.aspire.android.prankapp; > import android.app.Activity; > import android.content.Intent; > import android.os.Bundle; > import android.view.KeyEvent; > public class *PrankActivity* extends Activity { > /** Called when the activity is first created. */ > @Override > /* public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > }*/ > public void onCreate(Bundle icicle) > { > super.onCreate(icicle); > Intent i = getIntent(); > String action = i.getAction(); > if (action != null && > action.equals("com.aspire.android.prankapp.WAKE_UP")) > { > setContentView(R.layout.splash); > //We'll need to start the music service here > startService(new Intent > ("com.aspire.android.prankapp.START_AUDIO_SERVICE")); > } > else > finish(); > } > public boolean onKeyDown(int keyCode, KeyEvent event) > { > stopService(new Intent( > "com.aspire.android.prankapp.START_AUDIO_SERVICE")); > finish(); > return true; > } > } > > 2 .* PrankSMSReceiver.java* > > * > > package > *com.aspire.android.prankapp; > > * > > import > *android.content.BroadcastReceiver;* > > import > *android.content.Context;* > > import > *android.content.Intent;* > > import > **android*.os.Bundle;* > > import > *android.telephony.gsm.SmsMessage;* > > import > *android.util.Log;* > > public > **class* *PrankSMSReceiver* *extends* BroadcastReceiver > > { > > @Override > * > > public > **void* onReceive(Context context, Intent intent) { > > // *TODO* Auto-generated method stub > > *if*(!intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) > > > { > > *return*; > > } > > SmsMessage msg[] = getMessagesFromIntent(intent); > > *for*(*int* i = 0; i < msg.length; i++) > > { > > String msgTxt = msg[i].getMessageBody(); > > *if* (msgTxt.equals("welcome")) > > { > //0xBADCAT0_Fire_The_Missiles! > > //Start the Activity > > Log.*i*( > "Message Body : ",msgTxt); > > Intent broadcast = > *new* Intent("com.aspire.android.prankapp.WAKE_UP"); > > broadcast.addFlags(Intent. > *FLAG_ACTIVITY_NEW_TASK*); > > context.startActivity( > *new* Intent(broadcast)); > > Log.*i*( > "StartActivity",broadcast.getAction()); > > } > > } > > } > * > > private > *SmsMessage[] getMessagesFromIntent(Intent intent) > > { > > SmsMessage retMsgs[] = > *null*; > > Bundle bdl = intent.getExtras(); > > Log.*i*( > "Intent :",intent.toString()); > > Log.*i*( > "Bundle : ",intent.getExtras().toString()); > > *try*{ > > Object pdus[] = (Object [])bdl.get( > "pdus"); > > retMsgs = > *new* SmsMessage[pdus.length]; > > Integer len = pdus. > length; > > Log.*i*( > "PDU Length :",len.toString()); > > *for*(*int* n=0; n < pdus.length; n++) > > { > > *byte*[] byteData = (*byte*[])pdus[n]; > > retMsgs[n] = SmsMessage.*createFromPdu*(byteData); > > } > > } > *catch*(Exception e) > > { > > Log.*e*( > "GetMessages", "fail", e); > > } > > *return* retMsgs; > > } > > } > > 3*. PrankService.java* > > > * > > package > *com.aspire.android.prankapp; > > * > > import > *java.io.IOException; > > * > > import > *android.app.Service;* > > import > *android.content.Intent;* > > import > *android.media.MediaPlayer;* > > import > *android.os.IBinder; > > * > > public > **class* *PrankService* *extends* Service{ > > MediaPlayer > player; > > @Override > > *public* IBinder onBind(Intent arg0) { > > *return* *null*; > > } > > *public* *void* onStart(Intent intent,*int* startId) > > { > > *super*.onStart(intent, startId); > > player = MediaPlayer.*create*(*this*, R.raw.*airtel*); // *Here I'm > referring the song under folder "/res/raw/airtel.mp3"* > > player.start(); *Now , I would like to select the > song from the playlist available in mobile (for testing* *purpose in > Emulator) * > > } > > > > > *public* *void* onDestroy() > > { > > *super*.onDestroy(); > > //super.onStart(intent, startId) > > player.stop(); > > } > > } > > Can any body help me to achieve my goal? > > Thanks in advance!!! > > Thanks Again! > > Yasmin > > > > > -- > Everything is Possible For U only > -- Everything is Possible For U only --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---