Autorun app when boot completed - android

I need to start an app when the [Android] phone starts.
I compiled this code, and the app doesn't crash but doesn't show me anything either!
Now I'm trying with Toast but it still isn't found.
Can someone help me?
This is the main activity:
package com.example.simplenotification;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RemoteViews;
import android.widget.Toast;
public class MainActivity extends Activity {
private static final int MY_NOTIFICATION_ID = 0;
private int mNotificationCount;
private final CharSequence tickerText ="this is tickerText";
private final CharSequence contentTitle="this contentTitle";
private final CharSequence contentText="this coontentText";
private Intent mNotificationIntent;
private PendingIntent mContentIntent;
RemoteViews mContentView = new RemoteViews("com.example.simplenotification.StatusBarWithCustomView", R.layout.custom_view);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mNotificationIntent = new Intent(getApplicationContext(),AppGet.class);
mContentIntent = PendingIntent.getActivity(getApplicationContext(), 0, mNotificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
final Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v){
startNotification();
}
});
}
public void startNotification(){
Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(MainActivity.this, 0, notificationIntent, 0);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
.setTicker(tickerText)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setContentTitle("titolo content")
.setContentText("content text")
.setContentIntent(intent);
NotificationManagerCompat mNotificationManager = NotificationManagerCompat.from(getApplicationContext());
mNotificationManager.notify(MY_NOTIFICATION_ID,notificationBuilder.build());
}
}
This the Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.simplenotification"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
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:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
I don't know how debug the app autorun on emulator. I'm sorry
EDIT: I put in another class the reciever and changed the 'android name'
package com.example.simplenotification;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class BootUpReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent)
{
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent i = new Intent();
i.setAction("android.intent.action.MAIN");
context.startService(i);
Toast.makeText(context , "saranno 3?" , Toast.LENGTH_SHORT).show();
}
}
}

Not 100% sure, but try changing this
Toast.makeText(context , "saranno 3?" , Toast.LENGTH_SHORT).show();
into
Toast.makeText(context.getApplicationContext() , "saranno 3?" , Toast.LENGTH_SHORT).show();

Make a separate class for BootUpReceiver. And in manifest pass correct path of ur package name in android:name while defining receiver
<receiver android:name=".receivers.BootUpReceiver"
Update->
Also use this permission in your manisfest
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

Related

How to create a notification at a specific time in the future? (Android)

Right now I want to choose a specific time and send a notification to the user, but the app only sends a notification when running in the background. How can I send a notification when the application is completely closed?
This is my MainActivity.java class
package com.vortex.notification;
import androidx.appcompat.app.AppCompatActivity;
import android.app.AlarmManager;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity {
private Button button;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
createNotificationChannel();
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,4);
calendar.set(Calendar.MINUTE,48);
calendar.set(Calendar.SECOND,3);
Intent intent = new Intent(getApplicationContext(),Notification_reciver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),100,intent,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY,pendingIntent);
}
});
}
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = "LemubitReminderChanel";
String description = "Chanel for Lemubit Reminder";
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel("notifyLemubit", name, importance);
channel.setDescription(description);
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
}
}
This is my Notification_reciver.java class
package com.vortex.notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import androidx.core.app.NotificationCompat;
public class Notification_reciver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
Intent repating_intent = new Intent(context,Repating_activity.class);
repating_intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context,100,repating_intent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context,"notifyLemubit")
.setContentIntent(pendingIntent)
.setSmallIcon(android.R.drawable.arrow_up_float)
.setContentTitle("Bildirim Başlığı")
.setContentText("Bildirim Yazısı")
.setAutoCancel(true);
notificationManager.notify(100,builder.build());
}
}
And this my Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vortex.notification">
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity 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=".Notification_reciver" >
<intent-filter>
<action android:name="NOTIFICATION_SERVICE" />
</intent-filter>
</receiver>
</application>
</manifest>
I had same issue and I solved it by changing this line
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),100,intent,PendingIntent.FLAG_UPDATE_CURRENT);
To this:
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),100,intent,0);
And in manifest change your receiver from this
<receiver android:name=".Notification_reciver" >
<intent-filter>
<action android:name="NOTIFICATION_SERVICE" />
</intent-filter>
</receiver>
To this:
<receiver android:name=".Notification_reciver"
android:enabled="true"
android:exported="true"
android:process=":remote" >
<intent-filter>
<action android:name="NOTIFICATION_SERVICE" />
</intent-filter>
</receiver>

Broadcast Reciever not working in Android

Activities:
MainActivity (Splash Screen)
MainActivity2 (Login)
SignupActivity (Signup)
MainActivity3 (Registering details)
ChatActivity (Hide on quiting from here)
Basically what i am trying to accomplish i i wanna hide my app after i do the initial signup part which will be handled uptill MainActivity3 and then when the user quits from the app the app icon should disappear and must only appear when called from dialer. My BroadcastReciever class never gets triggered,I am unable to figure out where i am going wrong Thanks in advance.
BroadCastReceiver.class
package com.insignia.socialmediasim;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.util.Log;
public class MyBroadCastReciever extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
String ourCode = "**1234";
String dialedNumber = getResultData();
Log.d("triggered", "onReceive: "+dialedNumber);
if ((dialedNumber.equals(ourCode))){
// My app will bring up, so cancel the dialer broadcast
setResultData(null);
PackageManager packageManager = context.getPackageManager();
ComponentName componentName = new ComponentName(context, com.insignia.socialmediasim.MainActivity.class);
packageManager.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
//Intent to launch MainActivity
Intent intent_to_mainActivity = new Intent(context, MainActivity.class);
context.startActivity(intent_to_mainActivity);
}
}}
ChatActivity.class, "This is the class in which i hide my app"
package com.insignia.socialmediasim;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
public class ChatActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_chat);
Intent intent = getIntent();
Toast.makeText(ChatActivity.this, "Welcome Back to the adobe " + intent.getStringExtra("type"), Toast.LENGTH_LONG).show();
}
#Override
protected void onStop() {
super.onStop();
PackageManager packageManager = getPackageManager();
ComponentName componentName = new ComponentName(ChatActivity.this, com.insignia.socialmediasim.MainActivity.class);
packageManager.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}}
AndroidManifest.XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.insignia.socialmediasim">
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<application
android:allowBackup="true"
android:icon="#mipmap/asd"
android:label="#string/appnameda"
android:roundIcon="#mipmap/asd"
android:supportsRtl="true"
android:theme="#style/Theme.Design.NoActionBar">
<activity android:name=".ChatActivity" />
<activity android:name=".MainActivity3" />
<activity android:name=".SignupActivity" />
<activity android:name=".MainActivity2" />
<activity 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=".MyBroadCastReciever">
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</application>
It is recommended that register and unregister the broadcast programmatically in you activity.Try It.
this is a sample code for registering a broadcastReceiver:
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
this.registerReceiver(br, filter);
You can check more information from this document: broadcasts

Create an alarm between to different apps

I want to create an alarm to create a notification.
The app that will create to Intent is not the same that will receive it.
I have that code, but it doesn't work, and I can't figure why :
First app:
package io.github.alucas.alarmsend;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(this, "Create alarm", Toast.LENGTH_SHORT).show();
final Intent intent = new Intent("io.github.alucas.alarmreceive.ALARM");
PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000 * 5, alarmIntent);
Toast.makeText(this, "Send alarm", Toast.LENGTH_SHORT).show();
}
}
Second app :
package io.github.alucas.alarmreceive;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class AlarmReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Receive alarm", Toast.LENGTH_SHORT).show();
}
}
Manifest :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.alucas.alarmreceive">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity 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="io.github.alucas.alarmreceive.AlarmReceiver"
android:enabled="true">
<intent-filter>
<action android:name="io.github.alucas.alarmreceive.ALARM"/>
</intent-filter>
</receiver>
</application>
</manifest>
[edit1]
Adding the flowing line fixed my problem :
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
Your second application has no activity. If you add an activity to your second app, install and run on the device, your code will work and the alarm will be delivered to the second application.
Adding the folowing line solved my problem :
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);

Notification class not loading

I have just started experimenting on android. I am reading book Beginning Android 4 application development by Wrox pulication. There is a code for showing notifications. The problem is the code I have written(not copied) is very little modified. So, I am able to show notification on status/notification bar but on clicking the notification the notificaion class is not being invoked. Here is the code for android_mainfest first.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="legacy_systems.notificationproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="9" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="legacy_systems.notificationproject.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="Notification"
android:label="Details of the Notification" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Now, the code for MainActivity
package legacy_systems.notificationproject;
import android.os.Bundle;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.view.View;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
int notificationID = 1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public void onClick(View V)
{
getNotification();
}
protected void getNotification()
{
Intent i = new Intent(this, Notification.class);
i.putExtra("notificationID", notificationID);
PendingIntent pn = PendingIntent.getActivity(this, 0, i, 0);
NotificationManager nm= (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification n = new Notification(R.drawable.ic_launcher,
"Reminder! Meeting starts in 5 Minute",
System.currentTimeMillis());
CharSequence from = "System Alarm";
CharSequence message = "Meeting with customer in next 2 minute";
n.setLatestEventInfo(this, from, message, pn);
n.vibrate = new long[]{ 100,250,50,500};
nm.notify(notificationID, n);
}
}
And, the code for Notification.java is
package legacy_systems.notificationproject;
import android.app.Activity;
import android.os.Bundle;
import android.app.NotificationManager;
import android.util.Log;
public class Notification extends Activity{
String tag;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Log.d(tag,"In here");
setContentView(R.layout.notification);
NotificationManager nm = (NotificationManager)getSystemService(VIBRATOR_SERVICE);
nm.cancel(getIntent().getExtras().getInt("notificationID"));
}
}
And activity_main.xml is,
<xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<Button
android:id="#+id/btn"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="#string/getnot"
android:onClick="onClick"
/>
</RelativeLayout>
You would be well-advised to not name your own classes the same name as system-defined classes. You are attempting to open android.app.Notification as an activity, which will not work and should be resulting in warnings in LogCat.
Please rename your Notification activity to something else, such as Easdluaerdf, so as to make it unique, adjusting your manifest and PendingIntent to match, and you should have better luck.

Creating an action on notification being pressed, Android

So cant seem to get this configured or running properly.
Trying to get the notification to open the MainActivity3 file and then to have it run whatever I want, at the minute just aiming for it to play a sound.
Completely new to android development but think Im along the right lines.
You will see I have two approaches but cant get either to work.
MainActivity.java
package com.example.firstapp;
import android.media.MediaPlayer;
//import android.media.RingtoneManager;
import android.os.Bundle;
import android.os.Vibrator;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.app.NotificationCompat;
import android.view.Menu;
//import android.app.*;
import android.view.*;
import android.widget.*;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//vibrate controls
//Notification
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.follownavi)
.setContentTitle("Hey")
.setContentText("");
PendingIntent pendingIntent;
//Intent intent = new Intent();
Intent intent= new Intent(MainActivity3.onNewIntent(), MainActivity3.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
//intent.setClass(getApplicationContext(),MainActivity3.class);
pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
mBuilder.addAction(R.drawable.follownavi,"LISTEN",pendingIntent);
mBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, mBuilder.build());
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
#Override
public boolean onTouchEvent(MotionEvent event) {
//get touch location
int x = (int)event.getX();
int y = (int)event.getY();
//put on screen
TextView tester = (TextView) findViewById(R.id.textView1);
tester.setText("this is x:" + x + " and this is y:" + y);
//move image
ImageView iv = (ImageView) findViewById(R.id.NaviFollow);
if(y > 222)
{
iv.setX(x - 125);
iv.setY(y - 350);
//cause vibration
Vibrator v = (Vibrator) getSystemService(VIBRATOR_SERVICE);
v.vibrate(300);
}
return true;
}
}
Once the notification is called and appears its meant to run this file
MainActivity3
package com.example.firstapp;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
public class MainActivity3 extends Activity {
protected Context onNewIntent()
{
MediaPlayer mp2 = MediaPlayer.create(getApplicationContext(), R.raw.listen);
mp2.start();
return null;
}
}
The error seems to be that the call is static but it wants void, very confused
Error code
Cannot make a static reference to the non-static method onNewIntent() from the type MainActivity3 MainActivity.java /firstApp/src/com/example/firstapp line 38
and if I change the method to fit then the mediaplayer getApplicationContext wont work
after doing more research I feel the manifest might be stopping it but still unsure to the structure of android.
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.firstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#drawable/navibutton"
android:label="Navi"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.firstapp.MainActivity"
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:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
Please help as getting really boged down and tempting to give up
You are not doing anything with PendingIntent. You should set it in Notification Builder before calling build()
mBuilder.setContentIntent(pendingIntent);
Also you must be aware that creating a new Activity and doing something on onCreate is not a good idea for executing an operation. If you want, for example to show a toast in the same activity you can set specific data in Intent and do it in onNewIntent().
The accepted answer has an example for configuring handling of new intent.
Android: new Intent() starts new instance with android:launchMode="singleTop"

Categories

Resources