Broadcastreceiver can be called from ADP but not other apps - android

I have a broadcast receiver I am using to display some notification. I can call it and have it be correctly triggered using ADB. But calling it from within another app does nothing.
The receiver does live in/on a Android Wear app/device.
Receiver
<receiver android:name=".NotificationReceiver" android:exported="true">
<intent-filter>
<action android:name="site.com.app.SHOW_NOTIFICATION" />
</intent-filter>
</receiver>
Call from ADB
./adb -s SERIAL shell am broadcast -a site.com.app.SHOW_NOTIFICATION
Call from App
Intent i = new Intent();
i.setAction("site.com.app.SHOW_NOTIFICATION");
i.putExtra("contentText", "Some Text");
sendBroadcast(i);
I'm not sure why it would work from ADB but not from another App, any ideas?

I don't know exact your code but you can try below code which I have made for you.
**Second Application**
package com.example.jiteshmohite.callingbroadcast;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
private Button button;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
lunchExportedBroadcast();
}
});
}
private void lunchExportedBroadcast() {
Intent intent = new Intent();
intent.setAction("com.example.exportedreceiver");
sendBroadcast(intent);
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.jiteshmohite.callingbroadcast.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="#+id/textView" />
<Button
android:text="Call Broadcast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="13dp"
android:layout_marginStart="13dp"
android:layout_marginTop="18dp"
android:id="#+id/button" />
</RelativeLayout>
**First Application who register broadcast**
public class ExportedReceiver extends BroadcastReceiver {
public ExportedReceiver() {`enter code here`
// empty constr
}
#Override
public void onReceive(Context context, Intent intent) {
// showing toast whenever any external application call these receiver.
Toast.makeText(context.getApplicationContext(), "ExportedReceiver", Toast.LENGTH_SHORT).show();
}
}
**Register receiver in First Application**
<receiver android:name=".receiver.ExportedReceiver">
<intent-filter >
<action android:name="com.example.exportedreceiver"></action>
</intent-filter>
</receiver>

Related

Toast and Broadcast receiver doesn't work

Hello i tried many times when i click the button it doesn't show the toast and broadcast receiver
the code attached down there kindly correct my miss takes its run successfully but when click the button nothing happend at all , I tried to edit in activity_main.xml but nothing happend
MainActivity.java
package com.example.myapplication;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
// broadcast a custom intent.
public void broadcastIntent(View view){
Intent intent = new Intent();
intent.setAction("com.myapplication.BOOT_COMPLETED"); sendBroadcast(intent);
}
}
MyReceiver.java
package com.example.myapplication;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class MyReceiver extends BroadcastReceiver{
#Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Intent Detected.", Toast.LENGTH_LONG).show();
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="MyReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.myapplication.BOOT_COMPLETED">
</action>
</intent-filter>
</receiver>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Example of Broadcast"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="30dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tutorials point "
android:textColor="#ff87ff09"
android:textSize="30dp"
android:layout_above="#+id/imageButton"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp" />
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:minWidth="48dp"
android:minHeight="48dp"
tools:ignore="SpeakableTextPresentCheck" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageButton"
android:layout_centerHorizontal="true"
android:onClick="broadcastIntent"
android:text="broadcast_intent" />
</RelativeLayout>
I hope this could help
import androidx.appcompat.app.AppCompatActivity;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
BroadcastReceiver br;
IntentFilter filter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
br = new MyReceiver();
filter= new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
}
public void broadcastIntent(View view){
Intent intent = new Intent();
intent.setAction("com.myapplication.BOOT_COMPLETED");
sendBroadcast(intent);
this.registerReceiver(br, filter);
}
}
also see this link
https://developer.android.com/guide/components/broadcasts
You are using a Manifest-declared receiver. This receiver would get invoked outside from other app or with some system events.
The receiver then becomes a separate entry point into your app which means that the system can start the app and deliver the broadcast if the app is not currently running.
If you want to trigger this receiver within the app you should register this receiver. In your case inside the MainActivity within onCreate or onResume as follows
broadcastReceiver = new MyReceiver ()
Intent filter = new IntentFilter("com.myapplication.BOOT")
registerReceiver(broadcastReceiver, filter)
Also you need to unregister it within onDestroy or onPause
unregisterReceiver(broadcastReceiver)
I guess you should use Context-registered receiver for your use case where you want to send a broadcast within the app. Its almost the same except that you don't need to define it inside the manifest.
More information here

Broadcast Receiver not showing result when broadcasting from another app Activity

I am trying to make broadcast receiver which will show a toast message when user click on button from my another app activity.
But receiver not showing result.
My code is below
My Receiver App
MyReceiver:
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class MyReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Broadcast has been received!", Toast.LENGTH_LONG).show();
}
}
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.xyz.receivebroadcast">
<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">
<receiver
android:name=".MyReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.example.xyz.broadcasts"></action>
</intent-filter>
</receiver>
</application>
My sender app
My MainActivity which sends the broadcasts is here.
MainActivity:
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void SendOutBroadcast(View view){
Intent i = new Intent();
i.setAction("com.example.xyz.broadcasts");
i.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
sendBroadcast(i);
}
}
activity_main.xml:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.xyz.broadcasts.MainActivity">
<Button
android:id="#+id/sendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="SendOutBroadcast"
android:text="Send Broadcast"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
In your case your activity Intent should be like this:
Intent intent = new Intent();
intent.setAction("com.example.xyz.broadcasts");
intent.putExtra("KeyName","code1id");
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
intent.setComponent(
new ComponentName("com.pkg.AppB","com.pkg.AppB.MainActivity"));
sendBroadcast(intent);
Try this may help you or visit for more information.
NOTE - This may be not going to work in Android O because in Android O implicit broadcast are ban as mentioned Here. (Also credits to you #Muhammad Arslan Maqsood)
i found the issue: issue is not with code, actually Android O disabled the feature "Implicit broasdcast". see this

FATAL EXCEPTION: java.lang.RuntimeException: Unable to instantiate service

I am beginner in android. i create a new service and run it in android mobile API Level-23. when i press button to startservice it show me ERROR. now i Create new project but problem is same there.
**FATAL EXCEPTION: java.lang.RuntimeException: Unable to instantiate service com.example.uzair.servicesapp.myIntentService: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference**
MainActivity.java
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private static int i =0;
private Intent ii;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ii = new Intent(this,myIntentService.class);
Toast.makeText(this, "this is custom toast", Toast.LENGTH_SHORT).show();
}
public void clickme2(View view)
{
startService(ii);
Toast.makeText(this, " Service start toast", Toast.LENGTH_SHORT).show();
}
public void clickme(View view) {
stopService(ii);
Toast.makeText(this, "Service stop toast", Toast.LENGTH_SHORT).show();
i++;
}
}
MyIntentService.java
import android.app.IntentService;
import android.content.Intent;
import android.widget.Toast;
public class myIntentService extends IntentService {
public myIntentService()
{
super("myIntentService");
Toast.makeText(this, "IntentService Constuctor toast", Toast.LENGTH_SHORT);
}
#Override
protected void onHandleIntent(Intent intent) {
Toast.makeText(this, "OnhandleIntent toast", Toast.LENGTH_SHORT);
}
#Override
public void onDestroy() {
super.onDestroy();
Toast.makeText(this, "Destroy toast", Toast.LENGTH_SHORT);
}
#Override
public void onCreate() {
super.onCreate();
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.uzair.servicesapp">
<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>
<service android:name=".myIntentService"/>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.uzair.servicesapp.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="#+id/textView" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="clickme"
android:text="#string/click_me"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="118dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:onClick="clickme2" />
</RelativeLayout>
Your are creating and stater service so you need to create an intent-filter to this service in the Manisfest file. In your manifest file edit:
<service android:name=".myIntentService">
<intent-filter>
<action android:name="com.example.uzair.servicesapp.myIntentService" />
</intent-filter>
</service>
Delete this line:
Toast.makeText(this, "IntentService Constuctor toast", Toast.LENGTH_SHORT);
First, you are not calling show() on any of your Toast objects, so none will display. Use Log.d() to log messages to LogCat instead.
Second, do not use this, or call inherited methods on a Service, from the constructor.
If that does not help, edit the question and post the entire Java stack trace, not just the error message.

Why placing a call programatically gives error message "Internet Calling not Supported"?

This is my code:
public String a_number;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_make_the_call);
//
callButton = (ImageButton)findViewById(R.id.call_button);
aCall = (TextView)findViewById(R.id.number_a);
a_number = aCall.getText().toString();
}
public void makeCallFunction(View view) {
String temp = "";
temp = "tel:"+a_number;
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(temp));
startActivity(callIntent);
}
My XML file contains:
<ImageButton
android:id="#+id/call_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="#drawable/dial"
android:onClick="makeCallFunction"/>
I have added the following in my manifest file:
<uses-permission android:name="android.permission.CALL_PHONE"/>
I searched my best for answers but found nothing helpful..
EDIT:
When I give a value directly, the call gets placed now.
Eg:
callIntent.setData(Uri.parse("tel:9876543210"));
But the problem remains when I read the number from my text view and try to place call with that number.
Can someone help me out?
Thanks in advance
If there's some alternate way to implement call, that'd help too.
Disable SIP Internet Calling and VoIP on your emulator or debugging device. This is the steps for Samsung Galaxy S4 :
go to settings > call > disable internet calling(in bottom)
I don't know what you are doing wrong, but see for yourself a working example :
MakeTheCallActivity.java
package com.example.makethecall;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MakeTheCallActivity extends ActionBarActivity {
private EditText mEditText;
private Button mButton;
private final String TAG = "MakeTheCallActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_make_the_call);
mButton = (Button)findViewById(R.id.call_button);
mButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mEditText = (EditText)findViewById(R.id.phone_number);
String phoneNumber = mEditText.getText().toString();
Log.d(TAG, phoneNumber);
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
startActivity(intent);
}
});
}
}
activity_make_the_call.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".MakeTheCallActivity"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/phone_number" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="call"
android:id="#+id/call_button" />
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sauravsamamt.makethecall" >
<uses-permission android:name="android.permission.CALL_PHONE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MakeTheCallActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
You can see I'm not using a hardcoded number. Make sure you enter a valid number. That's it.

Is it possible to start an activity after refusing a call?

My question is kinda simple, but as a total beginner im not able to find a way to start my activity when A phone call is refused(when the red button is pressed).
I'm looking into startActivityForResult() the past 30 minutes, but it seems impossible to me.
Do you have an Idea? I'm pretty sure that it can be done easily, but I'm just not able to spot the correct method.
It is very likely that we can do something better than this.
I played around a bit with Eclipse and this is what I managed to do.
The MainActivity is useless. If anything, can be used for insert of a button to activate the service.
The AfterActivity is the one that is launched at the end of a call.
The heart of the app is the phoneBroadcast. In this code you can see the management of the call and the launch of the application.
Please note the uses-permission in manifest, and the android action:
android.intent.action.BOOT_COMPLETED
for the phoneBroadcast receiver. This enables the automatic start of the receiver phoneBroadcast even after a reboot.
MainActivity.java :
/*
* AfterCall - simple demo for StackOverflow
* 2013 by Felice Murolo
*/
package com.fmtec.android.aftercall;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
#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.main, menu);
return true;
}
}
AfterActivity.java :
package com.fmtec.android.aftercall;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class AfterActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_after);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.after, menu);
return true;
}
}
phoneBroadcast.java :
package com.fmtec.android.aftercall;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
public class phoneBroadcast extends BroadcastReceiver {
private static final String TAG = "AfterCall-broadcastReceiver";
public phoneBroadcast() {
Log.d(TAG,"I'm into broadcast");
}
#Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG,"broadcastManager Receive");
TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
phoneStateListener customPhoneListener = new phoneStateListener();
telephony.listen(customPhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
Log.d(TAG,"CallState: "+telephony.getCallState());
/* YOUR ACTIVITY WAS LAUNCHED HERE */
if (telephony.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
Intent i = new Intent(context,AfterActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
phoneStateListener.java :
package com.fmtec.android.aftercall;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
public class phoneStateListener extends PhoneStateListener {
private static final String TAG = "AfterCall-phoneStateListener";
#Override
public void onCallStateChanged(int state, String incomingNumber){
//if (incomingNumber.length()>0) Log.d(TAG, incomingNumber);
switch(state){
case TelephonyManager.CALL_STATE_RINGING:
Log.d(TAG, "RINGING");
break;
case TelephonyManager.CALL_STATE_IDLE:
Log.d(TAG, "IDLE");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d(TAG, "OFFHOOK");
break;
}
}
}
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">AfterCall</string>
<string name="action_settings">Settings</string>
<string name="message">Hello, I\'m the MainActivity.</string>
<string name="message_after">Hello, I\'m the AfterActivity. I will show to you after a phonecall ending.</string>
<string name="title_activity_after">AfterActivity</string>
<string name="hello_world">Hello world!</string>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fmtec.android.aftercall"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.fmtec.android.aftercall.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:name="com.fmtec.android.aftercall.phoneBroadcast" >
<intent-filter android:priority="999" >
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name="com.fmtec.android.aftercall.AfterActivity"
android:label="#string/title_activity_after" >
</activity>
</application>
</manifest>
activity_main.xml (layout MainActivity)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="26dp"
android:text="#string/message"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
activity_after.xml (layout AfterActivity)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".AfterActivity" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:text="#string/message_after"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
A running service with access rights to the call state would be able to do such a thing.

Categories

Resources