andbook!.pdf - Learning Android Get an anddev.org - Android-Shirt Back to index
anddev.org Header Logo
FAQ Search Top rated articles Browse Feeds anddev.org - Authors Contact Details Register Log in

Launch Activity on System/Emulator Startup

Goto page Previous  1, 2, 3  Next
 
       anddev.org - Android Development Community | Android Tutorials | Index -> Novice Tutorials
Author Message
sbfalbo
Freshman


Joined: 26 Dec 2007
Posts: 8

PostPosted: Sun Feb 17, 2008 5:13 pm    Post subject: Reply with quote

Does anyone know if the BOOT_COMPLETED action is still valid in the new Android SDK build (m5 rc14)? I had the startup receiver working fine in the previous SDK build but now it seems to not be working. Thanks!
Back to top
View user's profile Send private message
sbfalbo
Freshman


Joined: 26 Dec 2007
Posts: 8

PostPosted: Fri Feb 22, 2008 1:41 pm    Post subject: Reply with quote

You need to add android.permission.RECEIVE_BOOT_COMPLETED to your AndroidManifest.xml as of SDK version m5-rc14.
Back to top
View user's profile Send private message
Delirio
Freshman


Joined: 03 Mar 2008
Posts: 6

PostPosted: Mon Mar 03, 2008 12:16 pm    Post subject: Reply with quote

Hi,


It still doesn't work with RECEIVE_BOOT_COMPLETED permission:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
I just get a "Permission Denial" warming message in the log:
WARN/ActivityManager(513): Permission Denial: receiving Intent { action=android.intent.action.BOOT_COMPLETED } from android requires android.permission.RECEIVE_BOOT_COMPLETED

how could I fix it?

Thanks in advance
Back to top
View user's profile Send private message
plusminus
Site Admin


Joined: 14 Nov 2007
Posts: 2102
Location: Germany

PostPosted: Mon Mar 03, 2008 1:41 pm    Post subject: Reply with quote

Hello Delirio,

please post your AndroidManifest.xml

Regards,
plusminus

_________________

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Delirio
Freshman


Joined: 03 Mar 2008
Posts: 6

PostPosted: Mon Mar 03, 2008 5:49 pm    Post subject: Reply with quote

Here you are:

XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="my.test">

     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />    
     <application android:icon="@drawable/icon" android:name="MainApplication">    
          <activity android:name=".ActTest" android:label="@string/app_name">
              <intent-filter>
                     <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
              </intent-filter>
         </activity>
         <receiver android:name="ReceiverTest">
               <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED"/>
                    <category android:name="android.intent.category.HOME" />                        
               </intent-filter>
          </receiver>
          <activity android:name="OtherActivity" android:clearOnBackground="false"/>
     </application>
</manifest>
Back to top
View user's profile Send private message
plusminus
Site Admin


Joined: 14 Nov 2007
Posts: 2102
Location: Germany

PostPosted: Mon Mar 03, 2008 7:06 pm    Post subject: Reply with quote

Hello delirio,

check whether this is your error:
XML:
<receiver android:name=".ReceiverTest">

insead of:
XML:
<receiver android:name="ReceiverTest">


Also check if the receiver is placed in the package "my.test".

Regards,
plusminus

_________________

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Delirio
Freshman


Joined: 03 Mar 2008
Posts: 6

PostPosted: Tue Mar 04, 2008 2:09 pm    Post subject: Reply with quote

Ok thanks,

I was just paying attention to the Logcat messages

The log keeps showing the Permission Denial warning but the IntentReceiver gets the BOOT_COMPLETED intent, so finally it works
Back to top
View user's profile Send private message
plusminus
Site Admin


Joined: 14 Nov 2007
Posts: 2102
Location: Germany

PostPosted: Tue Mar 04, 2008 2:36 pm    Post subject: Reply with quote

Hello Delirio,

maybe you need to reset the emulator once with -wipe-data to make the warning also disappear.

Regards,
plusminus

_________________

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Delirio
Freshman


Joined: 03 Mar 2008
Posts: 6

PostPosted: Tue Mar 04, 2008 3:34 pm    Post subject: Reply with quote

Hi plusminus,

nop, the warning persists but the code works

thanks very much anyway
Back to top
View user's profile Send private message
xayide
Junior Developer


Joined: 05 Feb 2008
Posts: 20

PostPosted: Tue Mar 25, 2008 5:16 pm    Post subject: Start a service?? Reply with quote

Hello!

I find this tutorial very interesting. I want to do something similar, but instead of launching an activity, i want to launch a service.

I try to do that this way:

Java:
public class TheService extends IntentReceiver {

    @Override
    public void onReceiveIntent(Context context, Intent intent) {    
         
                  Intent i = new Intent();
            i.setClass(context, MyPosition.class);
            Bundle b = new Bundle();
            startService(i,b);
      
    }
}


But the problem is that i canīt do startService(i,b) from an intentReceiver.

Is there anyway to launch a service from an intentReceiver?

thanks!!
Back to top
View user's profile Send private message
Delirio
Freshman


Joined: 03 Mar 2008
Posts: 6

PostPosted: Tue Mar 25, 2008 5:35 pm    Post subject: Reply with quote

Hi xayide,

Just use the context instance given in the method parameter:

context.startService(ib,b);
Back to top
View user's profile Send private message
xayide
Junior Developer


Joined: 05 Feb 2008
Posts: 20

PostPosted: Tue Mar 25, 2008 6:03 pm    Post subject: Reply with quote

I did that, but it doesnīt work at all!!

This is my manifest:
XML:

 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />  
        <service android:name=".anotherService" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </service>
        <receiver android:name=".TheService">
            <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
                 <category android:name="android.intent.category.HOME" />
            </intent-filter>
        </receiver>


the intent receiver

Java:
public class TheService extends IntentReceiver {

    @Override
    public void onReceiveIntent(Context context, Intent intent) {
     Log.d("iam in TheService","");
         /* Create intent which will finally start the Main-Activity. */
         Intent myStarterIntent = new Intent(context,anotherService.class);
         /* Set the Launch-Flag to the Intent. */
         myStarterIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
         /* Send the Intent to the OS. */
         Bundle b=new Bundle();
         //context.startService(myStarterIntent, );
         context.startService(myStarterIntent, b);           
    }
}


it doesnīt print the log.d text
Back to top
View user's profile Send private message
Delirio
Freshman


Joined: 03 Mar 2008
Posts: 6

PostPosted: Wed Mar 26, 2008 1:04 pm    Post subject: Reply with quote

Maybe the error is that the tag uses-permission is inside the application tag in your android manifest , it should be placed this way (or at least I think so):

XML:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.package">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <application android:icon="@drawable/icon" android:label="Application" android:name="Application">
        <receiver android:name=".anotherService" >
            <intent-filter>
                 <action  android:name="android.intent.action.BOOT_COMPLETED"  />
                 <category android:name="android.intent.category.HOME" />
            </intent-filter>
        </receiver>                  
    <service android:name="TheService" />
</application>
</manifest>
Back to top
View user's profile Send private message
xayide
Junior Developer


Joined: 05 Feb 2008
Posts: 20

PostPosted: Wed Mar 26, 2008 8:17 pm    Post subject: Reply with quote

Hi!

Itīs necessary to add all this permissions, otherwise it doesnīt work. It seems that with the new sdk release it is necessary to add all of them.

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_CELL_ID" />

However, it just work if i close the emulator and launch a new one. It doesnīt work if i relaunch just the application. I donīt know if it should do like this...

I have a question: do you have problems with the emulator? i launch it and sometimes it doesnīt appear in the ddms perspective, other times it gives me errors saying that the emulator is not found... Other times it gives errors such as, home is not responding, my application is not responding...

regards!
Back to top
View user's profile Send private message
stilwalli
Junior Developer


Joined: 21 Jul 2008
Posts: 18

PostPosted: Tue Jul 29, 2008 10:00 am    Post subject: android.intent.action.BOOT_COMPLETED Reply with quote

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.HelloWorld">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:icon="@drawable/icon">
<activity android:name=".HelloWorld" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".Start" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
</application>
</manifest>

package com.HelloWorld;

import android.content.Context;
import android.content.Intent;
import android.content.IntentReceiver;
import android.os.Bundle;
import android.util.Log;

public class Start extends IntentReceiver {

public void onReceiveIntent(Context context, Intent intent) {
if (intent.getAction().toString().equals("android.intent.action.BOOT_COMPLETED")) {
Log.i("Test", "121212");
Intent myStarterIntent = new Intent(context,HelloWorld.class);
/* Set the Launch-Flag to the Intent. */
myStarterIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
/* Send the Intent to the OS. */
Bundle b=new Bundle();
//context.startService(myStarterIntent, );
context.startService(myStarterIntent, b);
}
}

}

//HelloWorld is an activity that displays hello world.

I keep getting this error
WARN/PackageManager(510): Granting new permission android.permission.RECEIVE_BOOT_COMPLETED to android.server.PackageManagerService$SharedUserSetting@400c04d0
WARN/ActivityManager(510): Permission Denial: receiving Intent { action=android.intent.action.BOOT_COMPLETED } from android requires android.permission.RECEIVE_BOOT_COMPLETED


Please help
Back to top
View user's profile Send private message
Display posts from previous:   
       anddev.org - Android Development Community | Android Tutorials | Index -> Novice Tutorials All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


© 2007, Android Development Community
All rights reserved.
Powered by phpBB.