我的应用程序在使用intent启动活动时崩溃,但logcat中没有显示错误

时间:2017-04-25 18:28:26

标签: java android android-intent

这是主要活动

 public class MainActivity extends Activity {
    ///Lot of code here which does work
    Cursor pscod = db.rawQuery("SELECT * FROM myTable", null);
            Cursor phoneCode=db.rawQuery("SELECT * FROM myPhone", null);
            if(!(pscod.getCount()==0)&&!(phoneCode.getCount()==0))
            {
            Toast.makeText(getApplicationContext(),"hai",Toast.LENGTH_LONG).show();


                Intent dialogboxintent = new Intent(getApplicationContext(),FAQ.class);
                startActivity(dialogboxintent);
            }

我知道编译器确实会检查if条件并且在吐司确实发生之后进入内部。活动在清单文件中定义为

<activity android:name="com.example.profilechanger.FAQ"></activity>

新活动崩溃而没有显示我设置要查看的布局。 这是FAQ类

public class FAQ extends AppCompatActivity {
    ImageButton keyimage;
    SQLiteDatabase db;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.faq);
    db = openOrCreateDatabase("myDataBase.db", Context.MODE_PRIVATE, null);
    db.execSQL("CREATE TABLE IF NOT EXISTS myTable(passcode VARCHAR);");
    db.execSQL("CREATE TABLE IF NOT EXISTS masterPass(masterName VARCHAR,masterPassword VARCHAR);");
    db.execSQL("CREATE TABLE IF NOT EXISTS myPhone(lockPassword VARCHAR);");
    keyimage = (ImageButton) findViewById(R.id.keybutton);
    keyimage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Cursor pscod = db.rawQuery("SELECT * FROM myTable", null);
            Cursor phoneCode=db.rawQuery("SELECT * FROM myPhone", null);
            if (pscod.getCount()==0&&phoneCode.getCount()==0)
            {
                Toast.makeText(FAQ.this, "SET PASSCODE AND LOCKCODE", Toast.LENGTH_SHORT).show();
            }
            else
            {
                final Dialog masterDialog = new Dialog(FAQ.this);

                masterDialog.setContentView(R.layout.mastercode_enter_layout);
                masterDialog.setCancelable(false);
                masterDialog.setTitle("ENTER MASTER PASSWORD");

                final EditText master_edt_pass = (EditText) masterDialog.findViewById(R.id.master_editTextPasswordToLogin);
                Button master_btn_submit = (Button) masterDialog.findViewById(R.id.master_buttonSignIn);
                master_btn_submit.setOnClickListener(new View.OnClickListener() {

                    public void onClick(View v) {
                        // TODO Auto-generated method stub

                        // get The User name and Password
                        String masterPASSWORD = master_edt_pass.getText().toString();

                        // check if the Stored password matches with  Password entered by user
                        if (masterPASSWORD.trim().length()==0) {
                            showMessage("Error", "Please enter PASSWORD");
                            return;
                        }
                        Cursor c = db.rawQuery("SELECT * FROM masterPass WHERE masterPassword ='" + masterPASSWORD + "'", null);
                        if (c.moveToFirst()) {
                            showMessage("Success","LOGIN SUCCESS");
                            Intent profileIntent = new Intent(getApplicationContext(),Profile.class);
                            startActivity(profileIntent);
                            masterDialog.dismiss();
                        } else {
                            showMessage("Error", "Invalid attempt");
                            finish();
                        }
                    }
                });
                masterDialog.show();
            }

        }
    });

}

public void showprofilemode(View view) {
    android.support.v4.app.FragmentManager manager=getSupportFragmentManager();
    MyDialog myDialog=new MyDialog();
    myDialog.show(manager,"Profile");

}

public void callbackbutton(View view) {
    android.support.v4.app.FragmentManager manager2=getSupportFragmentManager();
    Callbackdialog calldialog=new Callbackdialog();
    calldialog.show(manager2,"Call Back");
}

public void locknowbutton(View view) {
    android.support.v4.app.FragmentManager manager3=getSupportFragmentManager();
    Locknowdialog locknowdialog=new Locknowdialog();
    locknowdialog.show(manager3,"Lock Now");
}

public void alerttonebutton(View view) {
    android.support.v4.app.FragmentManager manager4=getSupportFragmentManager();
    Alerttone alertnow=new Alerttone();
    alertnow.show(manager4,"Play Alert");
}

public void locationbutton(View view) {
    android.support.v4.app.FragmentManager manager5=getSupportFragmentManager();
    Location1 location=new Location1();
    location.show(manager5,"Get Location");
}

public void simchangebutton(View view) {
    android.support.v4.app.FragmentManager manager6=getSupportFragmentManager();
    Simchangedialog simchange=new Simchangedialog();
    simchange.show(manager6,"Sim Change");
}
public void showMessage(String title, String message) {

    AlertDialog.Builder builder;
    builder = new AlertDialog.Builder(this);

    builder.setCancelable(true);

    builder.setTitle(title);

    builder.setMessage(message);

    builder.show();

}

}

活动甚至没有显示视图FAQ布局 这是faq.xml文件

 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/faq"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.profilechanger.FAQ">

    <Button
        android:id="@+id/angry_btn"

        android:text="Changing the ring mode of the device"
        android:textColor="#2E3CFF"
        android:textSize="15sp"
        android:textAllCaps="false"
        android:onClick="showprofilemode"
        android:layout_width="1000dp"
        android:layout_height="60dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A7A6"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5"
        />
    <Button
        android:id="@+id/callbackbutton"
        android:layout_below="@+id/angry_btn"
        android:text="Getting a call back from the lost phone"
        android:textColor="#2E3CFF"
        android:textSize="15sp"
        android:textAllCaps="false"
        android:onClick="callbackbutton"
        android:layout_width="1000dp"
        android:layout_height="60dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A7A6"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5"
        />
    <Button
        android:id="@+id/locknowbutton"
        android:layout_below="@+id/callbackbutton"
        android:text="To Lock the phone"
        android:textColor="#2E3CFF"
        android:textSize="15sp"
        android:textAllCaps="false"
        android:onClick="locknowbutton"
        android:layout_width="1000dp"
        android:layout_height="60dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A7A6"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5"
        />
    <Button
        android:id="@+id/alertonebutton"
        android:layout_below="@+id/locknowbutton"
        android:text="To play alert tone"
        android:textColor="#2E3CFF"
        android:textSize="15sp"
        android:textAllCaps="false"
        android:onClick="alerttonebutton"
        android:layout_width="1000dp"
        android:layout_height="60dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A7A6"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5"
        />
    <Button
        android:id="@+id/locationbutton"
        android:layout_below="@+id/alertonebutton"
        android:text="To Track the Phone's location"
        android:textColor="#2E3CFF"
        android:textSize="15sp"
        android:textAllCaps="false"
        android:onClick="locationbutton"
        android:layout_width="1000dp"
        android:layout_height="60dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A7A6"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5"
        />
    <Button
        android:id="@+id/simchangebutton"
        android:layout_below="@+id/locationbutton"
        android:text="What happens when your sim is changed?"
        android:textColor="#2E3CFF"
        android:textSize="15sp"
        android:textAllCaps="false"
        android:onClick="simchangebutton"
        android:layout_width="1000dp"
        android:layout_height="60dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A7A6"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5"
        /><LinearLayout
    android:layout_below="@id/locationbutton"
    android:layout_marginTop="55dp"
    android:gravity="center_horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <ImageButton
        android:background="@drawable/change_passcode"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:id="@+id/keybutton"
        android:layout_gravity="center_horizontal" />
    </LinearLayout>
    </RelativeLayout>

Logcat甚至没有显示任何内容。请帮忙。

0 个答案:

没有答案