how to disable Notification bar throughout the application? [duplicate] - android

This question already has answers here:
how to disable notification bar for an android application? [duplicate]
(3 answers)
Closed 9 years ago.
The user can launch other installed applications from my application and back to my activity when exiting launched application.I want to disable notification bar(showed status of wifi,gps,bluetooth etc...) or pulling down of notification bar throughout my application .
It works for my application when setting requestWindowFeature(Window.FEATURE_NO_TITLE); But when launching other applications from my application ,possible to pull down Notification bar.
Is there any way to handle this?
Is it possible remove all notifications from Notification bar while my application is running?
How to make Notification bar not accessible from my application(a service is running throughout the application for checking currently running applications)?
Thanks in Advance

No it is not possible, and thank the lord for that.
Would be pretty horrible if one rogue app would block my notification bar in all other parts of the system and other apps.

You could us a theme in your AndroidManifest.xml:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
or use the following code snippet:
public class Activity
extends android.app.Activity
{
#Override
public void onCreate(android.os.Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}

Related

Show *only* a toast (no UI) after sharing text into an app?

I'm a starting Android developer and would like to know how to achieve this:
1# User is using e.g. Chrome
2# User wants to share the page (meaning: the URL, which is text) into an app
3# User chooses the app from the share menu
4# The app shows only a small notification on top of Chrome (current foreground app, which is the sender of the intent)
So the app would receive the intent from Chrome and do something with it, but wouldn't change the foreground app. It would stay in the background and show only a very small notification to the user that the sharing of the URL into this app actually succeeded. Toast or something like that.
This is basically the way for instance Pocket handles sharing into it.
How can I achieve this? IntentService? I cannot seem to find the correct answer to this. Theme.NoDisplay, Intent, IntentService – I cannot figure out the correct way since I'm not too familiar with Android yet.
Thank you a lot in advance!
Use the NoDisplay theme (update activity declaration in manifest) in the activity that does your sharing work as follows:
android:theme="#android:style/Theme.NoDisplay"
This will prevent the activity from being displayed.
Then once the activity starts, do your sharing task, display the Toast and call finish()
finish your activity onResume(). It will not shows any of Your Activity.
You can do like this:
protected void onResume() {
super.onResume();
finish();
}

Creating custom LockScreen in android [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am developing custom lockscreen app.its working fine in below 4.0 but above 4.0,when we press home button the app stops.is there any solution for this no apps will stop when pressing home button untill unlocking the screen.(like go locker app)
Another way to develop a LockScreen App is by using Views, let me explain it.
First of all you can "disable" in some devices the System lock screen by disabling the KEYGUARD:
((KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE)).newKeyguardLock("IN").disableKeyguard();
You should put this line of code in your Service.
After that you can launch an activity every time the screen goes off:
public class AutoStart extends BroadcastReceiver {
public void onReceive(Context arg0, Intent arg1) {
if(arg1.getAction().equals("android.intent.action.SCREEN_OFF")) {
Intent localIntent = new Intent(arg0, LockScreen.class);
localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
localIntent.addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
arg0.startActivity(localIntent);
}
}
}
If you read the documentation for WindowManager.LayoutParams.TYPE_SYSTEM_ERROR it explains that is a type of internal system error windows, appear on top of everything they can. In multiuser systems shows only on the owning user's window.
So now you have an activity on top of everything, but a press in HOME button will exit the activity.
Here is where the Views make their appearance. You can inflate a view from a layout resource and add it to the WindowManager as a TYPE_SYSTEM_ERROR, so will be on top of everything. And since you can control when to remove this View, the best place is in onDestroy of your Activity, because pressing the HOME button will only pause your activity, and the view will still be visible.
public WindowManager winManager;
public RelativeLayout wrapperView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
this.winManager = ((WindowManager)getApplicationContext().getSystemService(WINDOW_SERVICE));
this.wrapperView = new RelativeLayout(getBaseContext());
getWindow().setAttributes(localLayoutParams);
View.inflate(this, R.layout.lock_screen, this.wrapperView);
this.winManager.addView(this.wrapperView, localLayoutParams);
}
public void onDestroy()
{
this.winManager.removeView(this.wrapperView);
this.wrapperView.removeAllViews();
super.onDestroy();
}
To avoid the notification bar of showing I added the flags FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL | FLAG_LAYOUT_IN_SCREEN to consume all pointer events.
Not forget to add these two lines to your manifest:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
From here you just need to add the logic of your Lock Screen app to let the user use his smartphone :)
A custom launcher is basically an app (you can make it behave like a grid, list, implement your own drag and drop etc) then, you only need to add these lines to the intent filter of the main activity, with this done, after you install your app and press the home button your app will appear in the list of available homescreens.
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
What i cant find is a way to replace the lock screen, and hacks like disabling the lock screen on the phone and using an activity in a custom launcher isn't actually replacing the lockscreen ^^
You can use the below method to disable the Home key in android :
#Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
I am developing on a Samsung Galaxy S4 5.0 and what worked for me was simply changing getWindow().setFlags(..) to getWindow().addFlags(..)
I think first of all you should ask yourself if you really want to hijack the home key. Sometimes you may want it. But I think placing the app on the Android lock screen, letting the home key act normally and letting the underlying Android lock screen take care of password-protecting the device is what you actually want in a lot of cases (unless you want to change the way this is done by default).
Bottom line, letting an app be displayed on the Android lock screen comes pretty close to writing your own custom lock screen. And is decidedly easier since you don't have to manage passwords yourself. Not to mention it's safer and more reliable since you don't hijack the home key.
I did it like this and it works very well. You can see the details here:
show web site on Android lock screen
The question is about displaying a website on the lock screen, since that's what I was interested in, but the answer is more general, it works with any app.
You can see here an app that's on Google Play and has been written like this:
https://play.google.com/store/apps/details?id=com.a50webs.intelnav.worldtime

How to hide tablet bottom bar [duplicate]

This question already has answers here:
is it possible to hide the system bar
(5 answers)
Closed 9 years ago.
I am developing an application for tablet only, where the requirement is to run the app on the full screen of the tablet.
So please help me how to hide the tab bar because that apps is totally related to examination.
So back press, home and and other buttons are not required..
You cant hide that. How should a user quit your app without the bottom bar?
You can hide the bottom bar. But there is no direct method available. First you need to root the tab and then run the process to hide the bar. If you root the tab then the warranty will be void. And there is no unique method to root the tab (getting super user privileges), different tabs have different methods. And once you have rooted the tab, then you should do
//hide status bar
process = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
process.waitFor();
//show status bar
process = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
process.waitFor();
But this will work only for HoneyComb. For ICS and above try to find the code to hide status bar.
You can try below approach.
public class ActivityName extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
Or you can do it via your AndroidManifest.xml file:
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
</activity>

Android - How to Block the Notification Manager When our App Runs

I want to know how I can disable or block the Notification Manager, while my application is running.
Meaning that the user cannot use the Notification Manager, ie a notification should not pop up.
You have to make it fullscreen, either:
Via manifest:
<activity ...
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" />
</activity>
Or via code:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
I think you want to set activity as full screen. If so, try this it might help you.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Source: http://www.androidsnippets.com/how-to-make-an-activity-fullscreen
By blocking the notification manager do you mean blocking notifications from your app when your app is in the foreground? I'm looking for something similar, and I think creating a service to manage notifications that are shown that can be messaged by activities when they start and stop may be what is needed.

Android -> Status bar state changed

Is there a possibily within Android to get the state of the status bar, especially a new notification was added to it?
It need this to start an activity if something happend in the status bar. I don't mean the "Status bar windows".
Maybe I can use an IntentFilter like :
IntentFilter statusBarIntentFilter = new IntentFilter(android.bla.bla.ACTION_STATUSBAR_STATE_CHANGED);
Thank you so far in advanced!
BR
Is there a possibily within Android to get the state of the status bar, especially a new notification was added to it?
No, sorry. You cannot spy on other applications' notifications from the Android SDK.
Is there a possibily within Android to get the state of the status bar, especially a new notification was added to it?
You can listen for status bar notifications by using AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED.
Here is a StackOverflow answer on this subject, and here is a working example I put together based upon that answer. I actually put that example together because an application was, essentially, spamming my wife's notification bar with advertisements and there was no clear way of telling who the offending application was.

Categories

Resources