Application Development

  • Replies:4
  • OpenNot stickiedUnanswered

Nov 16, 2012 2:38:25 AM via Website

HI! i am a newbie to android development, i want to make simple stuff just like a view which has two buttons for sign in and sign up for example.
when i'm going to click the sign in it will open new activity for username and password. i already did that but when i run my application on my phone. it will install two apps for index and login.

Aug 30, 2013 12:46:41 PM via Website

i think you have done some mistake on The AndroidManifest.xml File.

<activity android:name="com.example.loacl.Home"
android:label="@string/general_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.local.Quit"
android:label="Quit">
<category android:name="android.intent.category.LAUNCHER" />
</activity>

Deactivated Account

Sep 17, 2013 2:16:14 PM via Website

Ask for professional assistance.

— modified on Sep 17, 2013 4:04:52 PM by moderator

Sep 19, 2013 7:53:57 AM via Website

Hi,

Check your manifest. it'a a simple demo. Run it and if it solves your problem check your manifest.

MainActivity

package com.example.gudia_test_pit;

import android.os.Bundle;
import android.widget.*;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends Activity implements OnClickListener {
protected Button b1,b2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 =(Button) findViewById(R.id.button1);
b2 = (Button) findViewById(R.id.button2);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}


@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.button1:{
Intent i = new Intent(this,Sign_In.class);
startActivity(i);
break;
}
case R.id.button2:{
break;
}
}

}

}


Sign_in Activity

package com.example.gudia_test_pit;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.*;

public class Sign_In extends Activity {
protected EditText t1,t2;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.sign_in);
t1 = (EditText) findViewById(R.id.editText1);
t2 = (EditText) findViewById(R.id.editText2);
}

}


main activity XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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=".MainActivity" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="33dp"
android:text="Sign_In" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentRight="true"
android:layout_marginRight="68dp"
android:text="Sign_Up" />

</RelativeLayout>


Sign_In Xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" >


</EditText>

<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />

</LinearLayout>


Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gudia_test_pit"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.demo_test_pit.MainActivity"//your package name
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="Sign_In"></activity>
</application>

</manifest>

Still issue share