how to hide default screen of incoming call - android

Any one know,how to hide default screen of incoming call..??
I want to hide default screen of incoming call.
Any kind of help appreciated.
Thank you

You can not remove default screen but you can replace with your own custom screen, below is method.
your app should handles the ACTION_ANSWER intent, and after you can display whatever screen you like.
For your app to handle intents you have to add intent filters to the app manifest file. This is fully described in the Intent class documentation. Here is a quick sample on how you could handle the ACTION_ANSWER intent:
<activity class=".MyCustomCallActivity"
android:label="#string/mycustomcall_title">
<intent-filter>
<action android:name="android.intent.action.ANSWER" />
</intent-filter>
...
</activity>

one option is to register broadcast receiver and set sendorderdbroadcast having higher priority. By setting higher priority intent, your onReceive will be worked first and from there you can able to show your own custom activity.

Related

Lollipop: making my activity stay in the task that launched the share intent

“My First App” has an activity that handles a “share” intent. Its activity in AndroidManifest.xml looks like this:
<activity
android:name="com.example.foo.myfirstapp.MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/jpeg"/>
</intent-filter>
</activity>
In KitKat, sharing an image from the album to “My First App” causes MainActivity to be part of the album’s task. This is the desired behavior.
In Lollipop, sharing an image from the album to “My First App” causes a new instance of “My First App” to be launched. If I look at the overview screen, the album task is there...and then there's a separate entry for "My First App". If I share another image, I wind up with two instances of "My First App"...etc.
Question: How do I make Lollipop process the share intent in the same way as KitKat?
Here's what I've done:
I notice that the intents sent from the Album have different flags set depending on the OS. (I got these using getIntent() and looking at mFlags.)
Kitkat: 0x80001 (524289): FLAG_GRANT_READ_URI_PERMISSION, FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
Lollipop: 0x18080001 (403177473): FLAG_GRANT_READ_URI_PERMISSION, FLAG_ACTIVITY_MULTIPLE_TASK, FLAG_ACTIVITY_NEW_DOCUMENT, FLAG_ACTIVITY_NEW_TASK
From reading http://developer.android.com/reference/android/content/Intent.html, it seems that these last three flags are causing the problem. Specifically
When paired with FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors (FLAG_ACTIVITY_NEW_DOCUMENT or FLAG_ACTIVITY_NEW_TASK) are modified to skip the search for a matching task and unconditionally start a new task.
I’ve been attempting to “override” these flags by specifying android:launchMode and android:documentLaunchMode in the activity in AndroidManifest.xml without success.
From http://developer.android.com/reference/android/R.attr.html#documentLaunchMode, using documentLaunchMode “never” seems promising, since
This activity will not be launched into a new document even if the Intent contains Intent.FLAG_ACTIVITY_NEW_DOCUMENT. This gives the activity writer ultimate control over how their activity is used.
but this didn't work.
I also considered android:taskAffinity, but there doesn’t seem to be a way to say “please prefer whatever task launched you”.
Afraid you can't do anything about this. It isn't under your control. This is a change in the way the "Album" app is launching its "share" Intent. If it doesn't want your Activity in its task, you can't force it in there.
If you have issues with having multiple instances of your "share" activity, you could declare your "share" activity as launchMode="singleTask" or launchMode="singleInstance" (depending on your needs. This may, however, break other things.

Filtering an Android Broadcast receiver by action and extra

I am able to filter the broadcasts in my Android application by action. Eg:
<receiver android:name=".receiver.TasksModifiedReceiver">
<intent-filter>>
<action android:name="myapp.TASKS_MODIFIED_ACTION" />
</intent-filter>
</receiver>
However, can I further filter them by "extras" that are supplied in the intent?
Eg, application A sends a broadcast:
Intent taskBroadcastIntent = new Intent();
taskBroadcastIntent.setAction(ApplicationConstants.TASKS_MODIFIED_BROADCAST_ACTION);
taskBroadcastIntent.putExtra("TaskType", taskType);
taskBroadcastIntent.putExtra("UserName", CommonCache.getCommonCache().getValue(CommonCache.USER_NAME));
taskBroadcastIntent.putExtra("Environment", Constants.ENVIRONMENT);
context.sendBroadcast(taskBroadcastIntent);
Now, application B should only receive the broadcast if "TaskType" extra is set to "task1",
and application C should only receive the broadcast if "TaskType" extra is set to "task2".
Any helpful suggestions would be appreciated.
I cannot find this ability in the Android developer documentation.
I dont think that is possible. But here is what I will do,
Create a common receiver, You will be receiving the app context and intent. So get the taskType using getStringExtra("TaskType") and based on that trigger the respective broadcast intent.

interrupting link to my app

I have a problem. I'm using the below code to interrupt links to my app as
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http" android:host="twitter.com"/>
<data android:scheme="http" android:host="facebook.com"/>
</intent-filter>
But the problem is that I need to set data scheme and host at runtime i.e. I can add or delete the host at runtime. How to set the value of data scheme and host at runtime? I am using below code but it is not working
IntentFilter filter = new IntentFilter();
filter.addAction("android.intent.action.VIEW");
filter.addCategory("android.intent.category.DEFAULT");
filter.addCategory("android.intent.category.BROWSABLE");
filter.addDataScheme("http");
filter.addDataAuthority("www.facebook.com", null);
RecieveBroadcaster receiver = new RecieveBroadcaster();
registerReceiver(receiver, filter);
Strictly speaking, the string corresponding to ACTION_VIEW is an activity action by convention; the fact that you place it into the intent-filter element of an activity in your manifest, makes it an activity action! The system listens for these on your application's behalf, which is basically why you don't (can't) listen for them yourself. The Context.startActivity() method generates these Intents.
The rules of intent resolution actually determine whether a particular Intent matches any IntentFilters. For activity intents, there may be multiple matches, and that usually displays the "Chooser" interface, so the user can select a target.
There are three Intent "streams" that never cross: startActivity(), sendBroadcast() and startService(). These are all initiated via methods in Context and each has a specific target Activity, BroadcastReceiver and Service respectively.
It is a simple matter to set up a BroadcastReceiver (not ReceiveBroadcaster did you even try that code?) to get the events you are interested in, and then use Context.startActivity() with the Intent you want. You can even use a custom action, so you know it was triggered by the receiver, and not the user.
The only question is: is there a broadcast event you can arrange to receive? There may be a system event you can register for, or you may be able to generate a custom event yourself, via Context.sendBroadcast().
Remember you can inspect the incoming Intent your activity was started with, and "forward" the same or a modified Intent if it doesn't exactly match what you are looking for. As you correctly determined, you cannot dynamically alter an activity's set of IntentFilters, so you will have to inspect the host of every request.
Remember you can also register receivers in your manifest as well, and have that implementation called automatically by the system.

Enale and disable SEARCH_LONG_PRESS in Android applications

I want my application to be opened by long-pressing search button, but I want to add the option to deactivate this.
I added to my shortcutActivity this:
<intent-filter>
<action android:name="android.intent.action.SEARCH_LONG_PRESS"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
so when I long-press the search button it is opened, but now, I have to be able to turn this feature on.
This is not the main activity, this activity just calls to the main one and then finish().
How can I do this?
Thank you.
Unfortunently intent filters are static
An intent filter is an instance of the IntentFilter class. However, since the Android system must know about the capabilities of a component before it can launch that component, intent filters are generally not set up in Java code, but in the application's manifest file (AndroidManifest.xml) as elements. (The one exception would be filters for broadcast receivers that are registered dynamically by calling Context.registerReceiver(); they are directly created as IntentFilter objects.)
This is from the IntentFilter Documetation.
Actually, this is easily done using the PackageManager:
ComponentName cnShortcutActivity = new ComponentName("my.package", "my.package.ShortcutActivity");
getPackageManager().setComponentEnabledSetting(cnShortcutActivity, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

Overriding the hardware buttons on Android

Is it possible to override the function of a hardware button programmically on a droid? Specifically, I'd like to be able to override the camera button on my phone programmically. Is this possible?
How to Handle Camera Button Events
As soon as camera button is pressed a broadcast message is sent to all the applications listening to it. You need to make use of Broadcast receivers and abortBroadcast() function.
1) Create a class that extends BroadcastReceiver and implement onReceive method.
The code inside onReceive method will run whenever a broadcast message is received. In this case I have written a program to start an activity called myApp.
Whenever hardware camera button is clicked the default camera application is launched by the system. This may create a conflict and block your activity. E.g If you are creating your own camera application it may fail to launch because default camera application will be using all the resources. Moreover there might be other applications which are listening to the same broadcast. To prevent this call the function "abortBroadcast()", this will tell other programs that you are responding to this broadcast.
public class HDC extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
// Prevent other apps from launching
abortBroadcast();
// Your Program
Intent startActivity = new Intent();
startActivity.setClass(context, myApp.class);
startActivity.setAction(myApp.class.getName());
startActivity.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
context.startActivity(startActivity);
}
}
}
2) Add below lines to your android manifest file.
<receiver android:name=".HDC" >
<intent-filter android:priority="10000">
<action android:name="android.intent.action.CAMERA_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
The above lines are added to your manifest file to tell the system that your program is ready to receive broadcast messages.
This line is added to receive an intimation when hardware button is clicked.
<action android:name="android.intent.action.CAMERA_BUTTON" />
HDC is the class created in step 1(do not forget the ".")
<receiver android:name=".HDC" >
The "abortBroadcast()" function is called to prevent other applications from responding to the broadcast. What if your application is the last one to receive the message? To prevent this some priority has to be set to make sure that your app receives it prior to any other program. To set priority add this line. Current priority is 10000 which is very high, you can change it according to your requirements.
<intent-filter android:priority="10000">

Categories

Resources