3

My problem is that I have an intent such as this one.

Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);     
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE);        
intent.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, artist);     
intent.putExtra(SearchManager.QUERY, artist);
if(intent.resolveActivity(getPackageManager()) != null)
{
startActivity(intent);
}

And what happens is when I test the app it asks an open with. So if I open the standard music android app it doesn't open but when I use Google music it works like a charm.

So if there is no choice and I must use Google music as no could one answered this question I am guessing it is some problem I don't know. But atleast is there a way to set it such that it opens only via Google music app. Like setting googlw music as the default application to open the particular intent sent only by my application without harming any other process.

I am a beginner in Android. And pls. pls. Do help me.

Community
  • 1
  • 1
KISHORE_ZE
  • 1,466
  • 3
  • 16
  • 26
  • Thanks for the answer. I'll try it and let you know. – KISHORE_ZE Aug 25 '15 at 14:07
  • try this one: http://stackoverflow.com/a/18068122/986169 – giorashc Aug 25 '15 at 14:07
  • I'm sorry giorashc but I'm a beginner in Android and that was for share intent so I couldn't modify it to use the send intent in my intent. – KISHORE_ZE Aug 25 '15 at 14:15
  • @giorashc Thanks giorashc for your effort. I really mean it. Thanks so much I atleast want to give you an up vote worth a +10 points. So please do post an answer of that comment. And anyway I figured it out. But I couldn't have done without your initiative. So pls do post an answer. – KISHORE_ZE Aug 25 '15 at 14:56
  • @giorashc please do put your answer. If you wish copy paste it even. I wait still tomorrow then I'll put mine as correct for the community. But please do post it. – KISHORE_ZE Aug 25 '15 at 15:05
  • thank you but its ok... the important thing you got it figured out. – giorashc Aug 25 '15 at 15:12
  • But please do. For me and the entire Stack Overflow Community. – KISHORE_ZE Aug 25 '15 at 17:24

1 Answers1

1

How it works.

I read in a particular article of stack overflow I don't know which. But but guy mention that to limit an send intent you could use intent.setClass however it requires knowing the activity name as well as the package name. But I don't know the activity name. So on a hunch I tried using intent.setPackage and Boom it worked. I would also like to thank giorashc for his efforts.

KISHORE_ZE
  • 1,466
  • 3
  • 16
  • 26