[android-developers] Re: My new issue...How can I select a song from playlist available in phone (or) Emulator ...

2008-11-04 Thread yasmin afrose
Hi Sutton,


Thanks for your response.

Thanks Again!!
Yasmin
On Tue, Nov 4, 2008 at 3:17 PM, Al Sutton <[EMAIL PROTECTED]> wrote:

>
> Patience is a virtue
>
> What have you tried while you've been waiting?
>
> Al.
>
> yasmin afrose wrote:
> > 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
> >
> >

[android-developers] Re: My new issue...How can I select a song from playlist available in phone (or) Emulator ...

2008-11-04 Thread yasmin afrose
Hi,

I didn't get any idea. I've added the following line in *PrankActivity.java*


startActivity(new Intent(

"com.aspire.android.prankapp.GetSongNameActivity"))

above line instead of

startService(" ") ;

Then,

I've modified the code within onStart() under PrankService.java

String action = intent.getAction();

String path = "E:/yasmin.matharussain/personal/entertain/A.R Hits/";

if(((action!=null)&&action.equals("com.aspire.android.prankapp.GetSongNameActivity"))&&!(getString(R.id.songname).equals(""))){

//setContentView(R.layout.splash);

path = path+getString(R.id.songname);

player = new MediaPlayer();

try {

player.setDataSource(path);

} catch (IllegalArgumentException e) {

// *TODO* Auto-generated catch block

e.printStackTrace();

} catch (IllegalStateException e) {

// *TODO* Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// *TODO* Auto-generated catch block

e.printStackTrace();

}

}else{

player = MediaPlayer.*create*(*this*, R.raw.*airtel*);

}

Then I've created one new file as *GetSongNameActivity.java*

package com.aspire.android.prankapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class GetSongNameActivity extends Activity implements OnClickListener
{
 TextView songname;
 Button proceed;

 /** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.songname);

songname = (TextView)this.findViewById(R.id.songname);

proceed = (Button)this.findViewById(R.id.proceed);
proceed.setOnClickListener(this);
}

 public void onClick(View v) {

  if(songname!=null){
Log.i("Song Name :",songname.toString());
startService(new
Intent("com.aspire.android.prankapp.START_AUDIO_SERVICE"));
  }else{
   Log.i("Song Name :", songname.toString());
  }

 }


}

Then I've created one more new file as *songname.xml*



http://schemas.android.com/apk/res/android";

>















But,

I can't get the output. User enters "Song Name" using the layout of *
songname.xml*
But, always the else part is worked ( I've marked that fully  else part as *red
color*).

===


On Tue, Nov 4, 2008 at 3:17 PM, Al Sutton <[EMAIL PROTECTED]> wrote:

>
> Patience is a virtue
>
> What have you tried while you've been waiting?
>
> Al.
>
> yasmin afrose wrote:
> > 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
> >
> > *
> >
> > 

[android-developers] Re: My new issue...How can I select a song from playlist available in phone (or) Emulator ...

2008-11-04 Thread Al Sutton

Patience is a virtue

What have you tried while you've been waiting?

Al.

yasmin afrose wrote:
> 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

[android-developers] Re: My new issue...How can I select a song from playlist available in phone (or) Emulator ...

2008-11-04 Thread yasmin afrose
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
-~--~~~~--~~--~--~---