Java 我如何打开一个Android应用程序直接进入一个不是主要活动的活动,然后移动到主要活动?
以下是我的主要活动-直到onCreate函数,没有导入。我把这定义为我父母的大部分活动。我希望我的应用程序在登录活动中打开-用户将在使用应用程序之前登录。他们登录后,我希望此活动打开Java 我如何打开一个Android应用程序直接进入一个不是主要活动的活动,然后移动到主要活动?,java,android,xml,Java,Android,Xml,以下是我的主要活动-直到onCreate函数,没有导入。我把这定义为我父母的大部分活动。我希望我的应用程序在登录活动中打开-用户将在使用应用程序之前登录。他们登录后,我希望此活动打开 public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { public final String APP_TAG = "MyCustomA
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
public final String APP_TAG = "MyCustomApp";
public final static int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 1034;
public String photoFileName = "photo.jpg";
public final int MY_PERMISSIONS_REQUEST_CAMERA = 66;
public static final int MEDIA_TYPE_IMAGE = 1;
public static final int MEDIA_TYPE_VIDEO = 2;
private static final int CAMERA_REQUEST = 1888;
final int REQUEST_LOG_IN = 666;
FirebaseDatabase database = FirebaseDatabase.getInstance();
String m_Text;
User user = null;
DatabaseReference myRef;
DatabaseReference userRef;
@Override
protected void onCreate(Bundle savedInstanceState)
{
//default text
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
tryGetUser();
}
以下是我的LoginActivity-直到onCreate函数,没有导入。我想成为第一个打开的页面
public class LoginActivity extends BaseActivity implements LoaderCallbacks<Cursor> {
final int RC_SIGN_IN = 101;
final int REQUEST_LOG_IN = 666;
/**
* Id to identity READ_CONTACTS permission request.
*/
private static final int REQUEST_READ_CONTACTS = 0;
/**
* Keep track of the login task to ensure we can cancel it if requested.
*/
private UserLoginTask mAuthTask = null;
// UI references.
private AutoCompleteTextView mEmailView;
private EditText mPasswordView;
private View mProgressView;
private View mLoginFormView;
private FirebaseAuth mAuth;
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mAuth = FirebaseAuth.getInstance();
setContentView(R.layout.activity_login);
// Set up the login form.
mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
populateAutoComplete();
mPasswordView = (EditText) findViewById(R.id.password);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
});
公共类LoginActivity扩展BaseActivity实现LoaderCallbacks{
最终整数RC_符号_IN=101;
最终int请求_LOG_IN=666;
/**
*身份识别读取\联系人权限请求的Id。
*/
私有静态最终int请求\u读取\u联系人=0;
/**
*跟踪登录任务,确保我们可以根据请求取消它。
*/
private UserLoginTask mAuthTask=null;
//用户界面引用。
私有AutoCompleteTextView mEmailView;
私有编辑文本mPasswordView;
私有视图mProgressView;
私有视图mloginfo视图;
私人消防队;
私人GoogleapClient MGoogleapClient;
@凌驾
创建时受保护的void(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mAuth=FirebaseAuth.getInstance();
setContentView(R.layout.activity\u登录);
//设置登录表单。
mEmailView=(AutoCompleteTextView)findviewbyd(R.id.email);
populateAutoComplete();
mPasswordView=(EditText)findViewById(R.id.password);
mPasswordView.setOnEditorActionListener(新的TextView.OnEditorActionListener(){
@凌驾
公共布尔onEditorAction(TextView TextView、int id、KeyEvent KeyEvent){
if(id==R.id.login | | id==EditorInfo.IME_NULL){
尝试登录();
返回true;
}
返回false;
}
});
只需将该活动设置为清单上的启动器活动,而不是默认的主活动
PS:请详细说明 你的问题和帖子代码不是截图。如果你不能帮助别人理解你自己,你希望得到什么帮助?代码是一个文本。请发布你的代码,而不是截图。这更好吗?这是我关于stackoverflow的第一个问题,所以我仍在研究如何提问,回答我的问题需要什么信息等。更好。谢谢你