i am new in this field
sorry for my bad english
i want to make an app that perform to open second layout and in 2nd layout i want to open first layout
but an error come on my intent kindly guide me
package com.example.ahmed.calling;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button= (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
setContentView(R.layout.my_layout2);
Intent intent = new Intent(getApplicationContext(),second.class);
startActivity(intent);
finish();
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
my second class is
public class second extends MainActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout2);
Button btn1 =(Button)findViewById(R.id.button2);
btn1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
startActivity(intent);
finish();
}
});
}
}
error come on clicking the button it appers on first activity
on line 25 i-e startactivity(intent) kindly guide me
my logcat error
10-15 00:32:14.968 26752-26752/? E/ConnectionService﹕ Failed to connect to GoogleApiClient: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
10-15 00:32:16.296 26939-26939/com.example.ahmed.calling E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.ahmed.calling/com.example.ahmed.calling.second}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
at android.app.Activity.startActivityForResult(Activity.java:3389)
at android.app.Activity.startActivityForResult(Activity.java:3350)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:748)
at android.app.Activity.startActivity(Activity.java:3562)
at android.app.Activity.startActivity(Activity.java:3528)
at com.example.ahmed.calling.MainActivity$1.onClick(MainActivity.java:25)
at android.view.View.performClick(View.java:4106)
at android.view.View$PerformClick.run(View.java:17052)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5059)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
manifest file is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ahmed.calling" >
<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>
</application>
</manifest>
I've spotted three logical errors/issues in your codes, however for being certain outputs of logcat are needed.
In your MainActivity class you don't need to change view hierarchy in that onClick callback. i.e. Remove setContentView(R.layout.my_layout2); in that method.
You shouldn't use getApplicationContext() inside an Activity to start another Activity. You should use the reference to current Activity instead.
Intent intent = new Intent(MainActivity.this, second.class);
startActivity(intent);
Also, there's no need to finish your Activities while you're starting another ones. They will be handled by the Android itself.
UPDATE #1:
Your logcat says:
Unable to find explicit activity class {com.example.ahmed.calling/com.example.ahmed.calling.second}; have you declared this activity in your AndroidManifest.xml?
This means that you should first declare your activities in the AndroidManifest.xml, then you can start them.
UPDATE #2:
Your final manifest file should look like this:
<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>
<!-- ADD THE FOLLOWING LINE -->
<activity android:name=".second"/>
</application>
As I suspected, your second Activity is not declared in the manifest. You need to add:
<activity android:name=".second"/>
Related
I did some research one this Exception but none of these answers here helped me. So what I need to do is when I click a list item, it moves to another activity but I end up getting the same annoying Exception. It tells to look into Android Manifest file but everything is alright there!
Here is my code
Intent:
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
String strItemTextView = mForecastAdapter.getItem(position);
Intent intent = new Intent(getActivity(), DetailActivity.class);
intent.putExtra(Intent.EXTRA_TEXT, strItemTextView);
startActivity(intent);
}
And Android Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.sunshine2">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.example.android.sunshine2.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.android.sunshine2.DetailActivity"
android:label="#string/title_activity_detail"
android:parentActivityName="com.example.android.sunshine2.MainActivity"
android:theme="#style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.android.sunshine2.MainActivity" />
</activity>
</application>
</manifest>
UPDATE:
Here is my code for DetailActivity:
package com.example.android.sunshine2;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
public class DetailActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.detail, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
return rootView;
}
}
}
I get an exception like this:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.android.sunshine2/com.example.android.sunshine2.DetailActivity}; have you declared this activity in your AndroidManifest.xml?
And it points to this line of the code:
intent.putExtra(Intent.EXTRA_TEXT, strItemTextView);
UPDATE #2:
Now things are getting really weird. If I use relative path for activity name BUT leave a full path for a Parent activity name (Code snippet of manifest file):
<activity
android:name=".DetailActivity" // <!--Activity I wanna go to (relative path)-->
android:label="#string/title_activity_detail"
android:parentActivityName="com.example.android.sunshine2.MainActivity"
android:theme="#style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.android.sunshine2.MainActivity" /><!--Full path-->
</activity>
I get the same Exception but this time it points to this line of code:
startActivity(intent);
UPDATE #3:
Please take a look at the comment I managed to fix my problem
You already have a declared package in your manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.sunshine2">
So as far as I remember you should just declare your activity in manifest with relative path only:
<activity
android:name=".DetailActivity"
android:label="#string/title_activity_detail"
android:parentActivityName=".MainActivity"
android:theme="#style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.android.sunshine2.MainActivity" />
</activity>
can you try below code
Intent intent = new Intent(view.getContext(), DetailActivity.class);
intent.putExtra(Intent.EXTRA_TEXT, strItemTextView);
So I managed to fix my problem. Since I am just learning on Udacity, after 2days of no answers I decided to look into the their solution. The problem is that their tutorials are about 1 year old and since then Android Studio was updated quite a lot. When you are creating a new project with fragment on the latest version of Android studio, for a layout you get three files:
activity_main.xml
content_main.xml
fragment_main.xml
As in previous versions of Android Studio, you wold only get two files:
activity_main.xml
fragment_main.xml
So what I did was I deleted content_main.xml and voilà. It worked!
That was really weird and I am marking this question as answered and I hope it will help for other users as well!
I am trying to launch and activity after boot.But app is getting crashed.
Its giving error
java.lang.RuntimeException: Unable to start receiver com.example.shoky.onboot.OnBoot: android.content.ActivityNotFoundException: Unable to find explicit activity class
OnBoot.java
package com.example.shoky.onboot;
import android.util.Log;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* Created by Shoky on 5/22/2016.
*/
public class OnBoot extends BroadcastReceiver {
#Override
public void onReceive(Context context,Intent intent){
Log.w("ASHOK","ONBOOT");
Intent myIntent = new Intent(context,MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shoky.onboot" >
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver android:name=".OnBoot"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name= "android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<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>
</application>
</manifest>
MainActivity.java
package com.example.shoky.onboot;
import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
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.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Try with changing this following in your manifest
<receiver
android:name=".OnBoot"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Do something like this in your OnBoot class
public void onReceive(Context context,Intent intent){
Log.w("ASHOK","ONBOOT");
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent myIntent = new Intent(context,MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
Add android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
inside receiver.
Include "category android:name="android.intent.category.DEFAULT"
inside intent filter.
<intent-filter>
<action android:name= "android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
Inside onReceive method,
Intent reference(myIntent) you have created is different with what you are calling at startActivity(intent).
Note: intent provided by onReceive method is used to filter the action event with which it has been registered.
Eg:
if(intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
{ `enter code here`
//code
}
I have setup an activity to be executed from a menu button. The activity is started and briefly appears and then crashes. I have added added activity to manifest file. Code poseted below. I have recently switched form Eclipse to Android Studio and still learning the changes.
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="#mipmap/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>
<activity
android:name=".Titles_Edit_Activity"
android:label="#string/title_activity_titles__edit_"
android:theme="#style/Theme.AppCompat">
</activity>
</application>
This is the logcat message:
08-13 11:13:45.841 15302-15302/com.example.jerry.els2015 D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
Menu trigger in MainActivity
public void setup(MenuItem menuItem){
Log.d("TAG", "Setting ");
startActivity(new Intent(this,Titles_Edit_Activity.class));
}
XML for Tiles_Edit_Activity
package com.example.jerry.els2015;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class Titles_Edit_Activity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_titles__edit_);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_titles__edit_, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
I found the issue on the activity. I setup menu and back button to finish and exit the system so bluetooth will be killed. I removed these option and was able to execute the new activity.
#Override
protected void onDestroy() {
super.onDestroy();
// finish();
// System.exit(0);
}
#Override
protected void onStop() {
super.onStop();
// finish();
// System.exit(0);
}
try other way for startactivity, ex;
Intent intent = new Intent(MainActivity.this, Titles_Edit_Activity.class);
startActivity(intent);
I found the issue on the activity. I setup menu and back button to finish and exit the system so bluetooth will be killed. I removed these option and was able to execute the new activity.
#Override
protected void onDestroy() {
super.onDestroy();
finish();
System.exit(0);
}
#Override
protected void onStop() {
super.onStop();
// finish();
// System.exit(0);
}
I am new to the Android development app. I was following the tutorials given in the official site. So far everything was good but when I started to create and modify the action bar, this error started to arise:
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Main AndroidManifest.xml at AndroidManifest.xml manifest:package attribute is not declared
My manifest file is this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="14"/>
package="com.mycompany.myfirstapp" >
<application>
<!-- The/main activity (it has no parent activity) -->
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo" >
<activity
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="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.hpcore.myfirstapp.MyActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.hpcore.myfirstapp.MyActivity" />
</activity>
</application>
</manifest>
And my main activity Java code is this:
package com.example.hpcore.myfirstapp;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import com.mycompany.myfirstapp.DisplayMessageActivity;
public class MyActivity extends ActionBarActivity {
public final static String EXTRA_MESSAGE= "com.hp core.myfirstapp.MESSAGE";
public void sendMessage(View view)
{
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE,message);
startActivity(intent);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_displaymessage);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_Activity_actions,menu);
return super.onCreateOptionsMenu(menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch (item.getItemId())
{
case R.id.action_search:
openSearch();
return true;
case R.id.action_settings:
openSettings();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
I guess the problem in one of these files.
You package attribute should be part of Manifest Tag-
Change your manifest Tag like below-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.myfirstapp" >
<uses-sdk android:minSdkVersion="14"/>
The scenario I have consists of 3 activities:
1- Homepage
2-Login
3-Register
The thing is now Home page has 2 buttons one login and one for homepage , and the login activity should be called from either this button or from inside register after I am done registering ,also both login and register activities inflate 2 different fragments.
The problem : Login activity doesnt start , instead it sometimes just blinks with the layout it should inflate for a split second and then backs to the previous activity whichever one it is , also when I replaced the login activity with another activity it started normally with no problems
Any idea what that might be.
NOTE: I'm not getting any errors or so
Signin Activity code:
package engezni.Activties;
import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
import Fragments.SigninFragment;
import engezni.Activties.R;
public class SignInScreen extends Activity {
FrameLayout frameLayout;
SigninFragment signinFragment;
TextView signinScreen;
#TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in_screen);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
getActionBar().setCustomView(R.layout.custom_action_bar);
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
/*Setting text to the textview in the xml actionbar layout */
signinScreen = (TextView) findViewById(R.id.actionbarTitleOrderScreen);
signinScreen.setText("Sign In");
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayShowHomeEnabled(false);
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar));
getActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.backlogo));
frameLayout=(FrameLayout)findViewById(R.id.signin_framelayout);
signinFragment=new SigninFragment();
if (findViewById(R.id.signin_framelayout) != null) {
if (savedInstanceState != null) {
return;
}
signinFragment.setArguments(getIntent().getExtras());
getFragmentManager().beginTransaction().add(R.id.signin_framelayout, signinFragment).commit();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.sign_in_screen, menu);
onBackPressed();
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
And then here is the manifest
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".SplashScreen"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen" >
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HomeScreen"
android:label="#string/title_activity_home_screen"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".SignInScreen"
android:label="#string/title_activity_sign_in_screen"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".RegisterScreen"
android:label="#string/title_activity_register_screen"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".MyActivity"
android:label="#string/title_activity_my" >
</activity>
</application>
Problem:
getMenuInflater().inflate(R.menu.sign_in_screen, menu);
onBackPressed();
When the onCreateOptionsMenu is called that is where you go back to the last activity because you called onBackPressed which will destroy your current activity.
solution:
remove the onBackPressed