Friday, March 12, 2010

Lanuch Application as Startup Application

In this article helps to lanuch your activity after the start your Phone.
1. Create a BroadcastReceiver Class and start your Main Activity
2. Set the User Permission for launch your application
3. Configure the Action and catgory in the intent-filter
4. Create a MainActivity

Create a BroadcastReceiver Class and start your Main Activity
    This BroadcastReceiver is used to receive the action and start the your main activity   

public class StartupActivity extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
   }
}


Set the User Permission for launch your application
Config the  " android.permission.RECEIVE_BOOT_COMPLETED " User Permission in the androidmanifest.xml

Configure the Action and catgory in the intent-filter
Set the following values for android and category

Action         :    android.intent.action.BOOT_COMPLETED
Category     :    android.intent.category.DEFAULT

Create a MainActivity
Create a MainActivity and write your logic there
public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
          }
}

Sample Code
MainActivity.java

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Toast.makeText(this, "Welcome to Application", Toast.LENGTH_LONG)
                .show();
        finish();
    }
}

BroadcastReceiver.java
public class StartupActivity extends BroadcastReceiver {
    /**
     * @see android.content.BroadcastReceiver#onReceive(Context,Intent)
     */
    @Override
    public void onReceive(Context context, Intent intent) {
        Intent i = new Intent(context, MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }
}

Androidmanifest.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
    package="com.lanuchactivity" xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:label="@string/app_name" android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <receiver android:name=".StartupActivity">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
                <category android:name="android.intent.category.DEFAULT"></category>
            </intent-filter>
        </receiver>
    </application>
    <uses-sdk android:minSdkVersion="7" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
</manifest>





18 comments:

  1. HOW MAKE AN STARTUP ANDROID APP ,THAT WILL SEND GPS LOCATION TO THE TOMCAT SERVER (USING JSP SERVLET)

    ReplyDelete
  2. Latest WhatsApp Group Links
    https://whatsappgrouplinq.com/

    ReplyDelete
  3. Really infomational and educative article thanks publisher for sharing this wonderful info i have shared this article on my blog tecktak flippzilla
    and whatsaup, and Best smart tv

    ReplyDelete
  4. Really This goes far beyond the commenting! It wrote his thoughts while reading the article amazingly :)

    성인야설

    ReplyDelete
  5. “I think commenting is the best part of my blogging – especially here at ProBlogger. You see I’m not that profound or wise, but many of my readers are. Comments add value to my blog. They take my posts to the next level and often take my ideas in rewarding new directions.” 스포츠마사지

    ReplyDelete
  6. I like the helpful info you provide in your articles. I’ll bookmark your blog and check again here frequently. I’m quite sure I’ll learn plenty of new stuff right here! 온라인카지노

    ReplyDelete
  7. The assignment submission period was over and I was nervous, 온라인사이트 and I am very happy to see your post just in time and it was a great help. Thank you ! Leave your blog address below. Please visit me anytime.


    ReplyDelete
  8. Excellent content ,Thanks for sharing this .,
    Leanpitch provides online training in ICP ACC, everyone can use it wisely.
    Certified Agile coach certification
    Agile coach

    ReplyDelete
  9. Excellent content ,Thanks for sharing this .,
    Leanpitch provides online training in ICP ACC, everyone can use it wisely.
    ICP ACC certification online
    Agile coach certification

    ReplyDelete
  10. I hope you can help me. I've been thinking about this for a long time, but I'm not getting it resolved.온카지노


    ReplyDelete
  11. Best Regulated Forex Brokers In Samoa Based On Independent Ratings, Reviews, And Online Presence. Find Out Which Broker You Should Choose.

    ReplyDelete

  12. https://haileypets.com
    https://poodlespring.com/
    https://www.cutespupsforsale.com/
    https://furkittens.com/

    ReplyDelete