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>
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>
It worked perfectly.
ReplyDeleteThanks!
Jessé
HOW MAKE AN STARTUP ANDROID APP ,THAT WILL SEND GPS LOCATION TO THE TOMCAT SERVER (USING JSP SERVLET)
ReplyDelete123movies
ReplyDeleteonline earning whatsapp groups
ReplyDeleteLatest WhatsApp Group Links
ReplyDeletehttps://whatsappgrouplinq.com/
Latest whatsapp groups
ReplyDeleteReally infomational and educative article thanks publisher for sharing this wonderful info i have shared this article on my blog tecktak flippzilla
ReplyDeleteand whatsaup, and Best smart tv
aşk kitapları
ReplyDeleteyoutube abone satın al
cami avizesi
cami avizeleri
avize cami
no deposit bonus forex 2021
takipçi satın al
takipçi satın al
takipçi satın al
takipcialdim.com/tiktok-takipci-satin-al/
instagram beğeni satın al
instagram beğeni satın al
btcturk
tiktok izlenme satın al
sms onay
youtube izlenme satın al
no deposit bonus forex 2021
tiktok jeton hilesi
tiktok beğeni satın al
binance
takipçi satın al
uc satın al
sms onay
sms onay
tiktok takipçi satın al
tiktok beğeni satın al
twitter takipçi satın al
trend topic satın al
youtube abone satın al
instagram beğeni satın al
tiktok beğeni satın al
twitter takipçi satın al
trend topic satın al
youtube abone satın al
takipcialdim.com/instagram-begeni-satin-al/
perde modelleri
instagram takipçi satın al
instagram takipçi satın al
takipçi satın al
instagram takipçi satın al
betboo
marsbahis
sultanbet
Really This goes far beyond the commenting! It wrote his thoughts while reading the article amazingly :)
ReplyDelete성인야설
Thank for this post. we want more 휴게텔
ReplyDelete“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.” 스포츠마사지
ReplyDeleteI 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! 온라인카지노
ReplyDeleteThe 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.
ReplyDeleteExcellent content ,Thanks for sharing this .,
ReplyDeleteLeanpitch provides online training in ICP ACC, everyone can use it wisely.
Certified Agile coach certification
Agile coach
Excellent content ,Thanks for sharing this .,
ReplyDeleteLeanpitch provides online training in ICP ACC, everyone can use it wisely.
ICP ACC certification online
Agile coach certification
I hope you can help me. I've been thinking about this for a long time, but I'm not getting it resolved.온카지노
ReplyDelete
ReplyDeletehttps://haileypets.com
https://poodlespring.com/
https://www.cutespupsforsale.com/
https://furkittens.com/