I want to hide my A activity from recent list, and i used excludeFromRecents="true", it works fine when i select home button and then select overview button, but when A activity is showing and i press overview button, activity exists in recent list, how can i hide A activity in that situation?
here is my activity tag in manifest :
android:name=".A"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:screenOrientation="portrait"></activity>
Related
I have tried to do some research on the topic and I am attempting to add an on-click listener for a button in a fragment in the main activity. So when I click a button in a fragment the click can get registered in the main activity file.
You can use custom broadcast receiver
You will register a receiver on button click in fragment
Then in activity apply action if this broadcast action equal to this custom action
you can use interface for this problem
when I create a new activity, Android Studio show me this photo:
It have a Back button but activity haven't it. how can I Make visible it?
put getSupportActionBar().setDisplayHomeAsUpEnabled(true); into onCreate() method in your activity class
In manifest declare the activity as a parent activity to get this button like this
<activity android:name="com.owletogroceries.activity.RewardsActivity"/>
<activity android:name="OrderConfirmationActivity"
android:parentActivityName="ProductActivity"/>
I am learning Navigation Drawer. In most of the examples given on internet, fragments are used.
My requirement is:
Home activity should contain Navingation Drawer
When I click on any item in the navigation drawer, a new activity should get opened with the BACK arrow (<--)
When I click on the BACK arrow, again I come to the Home screen with Navigation Drawer
If I look into most of the applications installed on my mobile like PayTM, all are operating like this.
My Approach
I am adding a Navigation Drawer Activity and making it the MAIN activity in the Manifest file like this:
<activity
android:name=".NavigationDrawerActivity"
android:label="#string/title_activity_navigation_drawer"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Adding BACK button in all other activities which open from the menu items of this drawer like this:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_class);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Question: Should I make Navigation Drawer Activity as Home Screen and call other activities from here (By clicking on menu items on the navigation drawer)? Is this the right approach? Do other applications also use this approach which use Navigation Drawer? If this is not the best approach, then how should I implement my requirement? Do I need fragments as mentioned in almost all the tutorials of Navigation Drawer?
Thanks!
Common NavigationDrawer Across All Activity Example is here
refer below Link for that
Common NavigationDrawer
this is Example of open Activity from NavigationDrawer and if u extend BaseActivity than NavigationDrawer will implement on that activity and where u do not want navigation drawer, do not extend BaseActivity
I have a screen in my app with a button to set date/time in the OS. I use startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS)) to open the android's date/time screen .
After setting the date/time , i return to my app screen using the back button in the android's status(notification) bar. After this, the notification bar never dissappears from my app screens. Its persistent until i restart my application. Is there a way to remove the notification bar?
I have added the line "android:theme="#android:style/Theme.NoTitleBar.Fullscreen" to all my activities and even at at the application level(just inside )
But still it never goes
Here is a part of my manifest
<activity
android:name="com.cyberonics.progsoundapp.ui.AlarmSettingScreen"
android:configChanges="keyboardHidden|orientation"
android:label="#string/title_activity_alarm_setting_screen"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
I also have the following code in my activity class
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN) before SetContentView()
Is there anything else i am missing?
Request your guidance on this
Thank you
I have an application with several activities.One of them is Login activity and this activity defined as MAIN in my app in manifest:
<activity
android:name="com.company.myapp.AuthorizationMainActivity"
android:label="#string/app_name"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The problem when my app enters background (e.g. I press home button) and then I open the app again - the Login page is showed to me. How can I show activity which was active for user at the moment application enter background?
If you don't explicitly want to use it for a special requirement, remove "android:launchMode="singleTask".
A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task. (found here at Android Developes)
Use a dummy activity as your base activity that launches and in that activity check to see if you need to display the login activity or another one. Then start that specific activity you want to go to from the dummy activity.
make sure you set the dummy activity to noHistory in the manifest so the user cannot navigate back to it
if(needsLogIn){
Intent i = new Intent(this,LoginActivity.class);
startActivity(i);
}else{
Intent i = new Intent(this,OtherActivity.class);
startActivity(i);
}
Remove android:launchMode="singleTask" > singletask activity will be the root and when you press home button all the activities above it will be removed. when you remove android:launchMode="singleTask" then the default behaviour will take place ie when you press home button and then launch again it will open the activity from where you left. have a look at the link http://developer.android.com/guide/components/tasks-and-back-stack.html