creating custom intent

by Bob » Thu, 30 Apr 2009 09:45:48 GMT


Sponsored Links
 Hi,
Can anyone tell me what I am doing wrong, I'm sure it is real simple.
I am trying to create a custom intent but everytime I try to launch it
from another activity I get a "No Activity found to handle Intent"
error?  Am I failing to register the new intent somehow even though it
is in the manifest?


Thanks,
Bob

In other activity,produces error:

 Intent i = new Intent("com.example.Intent1");
        startActivity(i);

In Receiver Activity:

In Manifest:

 <receiver android:name=".TestBroadcastReceiver"
android:enabled="true" >
             <intent-filter>
         <action android:name="com.example.Intent1" />

            </intent-filter>
        </receiver>


In Code File:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class TestBroadcastReceiver extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub

        }

}

--~--~---------~--~----~------------~-------~--~----~



creating custom intent

by Jeff Sharkey » Thu, 30 Apr 2009 11:33:09 GMT


 So because you're targeting a BroadcastReceiver, you would call
sendBroadcast() instead of startActivity().

j






-- 
Jeff Sharkey
jshar...@google.com

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


creating custom intent

by Bob » Thu, 30 Apr 2009 12:32:37 GMT


 > So because you're targeting a BroadcastReceiver, you would call

Thanks Jeff for quick response. What I want to do is start an activity
but I tried the Broadcast Receiver because I was getting the activity
not found error with the manifest like this:

 <activity  android:name=".MyActivity"  android:label="@string/
app_name">

              <intent-filter>
         <action android:name="com.example.Intent1" />

            </intent-filter>

Is there something wrong with that used in conjunction with
startactivity()?

Thanks,
Bob





--~--~---------~--~----~------------~-------~--~----~



creating custom intent

by Jeff Sharkey » Thu, 30 Apr 2009 13:09:48 GMT


 That code should have worked, as long as "MyActivity" is directly
inside of the android:package you defined in the manifest.  If it was
deeper you would have to reference the remaining sub-package leaves in
the android:name.

For example, if you had "com.example.uistuff.MyActivity" and your
manifest was only android:package="com.example", you would need to use
android:name=".uistuff.MyActivity" when defining that activity.

j









-- 
Jeff Sharkey
jshar...@google.com

--~--~---------~--~----~------------~-------~--~----~



creating custom intent

by Bob » Thu, 30 Apr 2009 14:35:54 GMT


 hanks for your help.  I believe I have resolved the problem and it
was that I didn't have the line

<category android:name="android.intent.category.DEFAULT" />

following

<intent-filter>
<action android:name="com.example.Intent1" />


Thanks Again,
Bob


On Apr 30, 1:09am, Jeff Sharkey <jshar...@android.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. [WTA] Bluetooth di acer liquid E

Maaf sebelum nya kalo udah di bahas tentang masalah ini. RR sekalian saya
ingin menanyakan kenapa bluetooth saya kok tidak
bs di turn on yah setelah di update ke froyo offcial. oh iya saya mengunakan
acer liquid e ferrari.

Adakah yg bs memberikan saya pencerahan.

-- 
===============
"

2. Nexian Journey dari selularshop

rasanya kalau nyari ke user minta harganya sama susah sob, soalnya dia
juga pasti penuh peluh keringat buat dapetin journeynya.




-- 
===============
"

3. Roms Apex 1.3

4. TableLayout two column?

5. android-2.2_r1.1 building issue...

6. Orientation specific layout

7. List view selector states