如何直接将Android应用程序打开到不是主要活动的活动,然后转到主要活动?

时间:2017-04-08 11:28:04

标签: java android xml

以下是我的mainActivity - 直到onCreate函数,没有导入。我将此定义为我的大多数活动父。我希望我的应用程序在登录活动中打开 - 用户将在使用该应用程序之前登录。他们登录后,我想要打开这个活动。

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;
        }
    });

1 个答案:

答案 0 :(得分:0)

只需将该活动设置为清单上的启动器活动,而不是默认主活动。

PS:请详细说明您的问题并发布代码而不是截图。如果你不能帮助自己被理解,你如何得到帮助?