send button click unfortunately "project name" has stopped - java

I have a button that sends the entered data to the database, After clicking on the button, an error appears unfortunately "project namе" has stopped, please, help!!!!
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kz.shoot.photo.photoshoot">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<!--uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" /-->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyMaterialTheme">
<activity
android:name=".LoginActivity"
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=".RegisterActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.RegisterActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MainActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
package kz.shoot.photo.photoshoot;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class MainActivity extends AppCompatActivity implements FragmentDrawer.FragmentDrawerListener {
private static String TAG = MainActivity.class.getSimpleName();
private Toolbar mToolbar;
private FragmentDrawer drawerFragment;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
drawerFragment = (FragmentDrawer)
getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar);
drawerFragment.setDrawerListener(this);
// display the first navigation drawer view on app launch
displayView(0);
}
#Override
public void onDrawerItemSelected(View view, int position) {
displayView(position);
}
private void displayView(int position) {
Fragment fragment = null;
String title = getString(R.string.app_name);
switch (position) {
case 0:
fragment = new PhotoShootFragment();
title = getString(R.string.title_home);
break;
case 1:
fragment = new HistoryFragment();
title = getString(R.string.title_history);
break;
case 2:
fragment = new AboutFragment();
title = getString(R.string.title_about);
break;
case 3:
finish();
break;
default:
break;
}
if (fragment != null) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.container_body, fragment);
fragmentTransaction.commit();
// set the toolbar title
getSupportActionBar().setTitle(title);
}
}}
Fragment_Photoshoot.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:orientation="vertical"
tools:context="kz.shoot.photo.photoshoot.PhotoShootFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<android.support.v7.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:id="#+id/label"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="30dp"
android:text="Мені? ?алам!"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12dp"
android:gravity="center_horizontal"
android:text="Жібергі?із келген жерді? суретін т?сірі?із!"
android:layout_below="#+id/label"
android:layout_alignParentStart="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/captured_photo"
android:contentDescription="#string/imageDesc"
android:theme="#android:style/Widget.ImageWell"
android:scrollIndicators="right"
android:layerType="hardware"
android:layout_centerVertical="false"
android:layout_centerInParent="false"
android:layout_alignWithParentIfMissing="false"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:minHeight="250dp"
android:maxHeight="300dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<Button
android:text="Камера"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/cameraBtn"
android:layout_below="#+id/captured_photo"
android:onClick="takePicture"
android:layout_centerHorizontal="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_margin="10dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/mess_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/mess_title"
android:imeOptions="actionNone"
android:inputType="text"
android:maxLines="1" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="Хабарлама категориясын та?да?ыз"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="#+id/category_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_margin="10dp"
android:layout_marginTop="0dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/message"
android:layout_marginTop="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="#string/photo_description"
android:inputType="text|textMultiLine"
android:maxLines="25"
android:elevation="0dp"
android:minHeight="82dp"
android:scrollbars="vertical"
android:scrollbarStyle="insideOverlay" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<Button
android:text="Жіберу"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/sendBtn"
android:layout_below="#+id/captured_photo"
android:layout_centerHorizontal="true" />
</LinearLayout>
</android.support.v7.widget.LinearLayoutCompat>
</LinearLayout>
</ScrollView>
</LinearLayout>

Related

How to fix 'Unable to start activity... null object reference'

Please excuse me not good at using english...
I'm a beginner in android programming.
I'm developing android alarm app, I want AlarmActivity to be displayed on the screen when AlarmReceiver is called.
But when AlarmService.onCreate is called, an error occurs.
Process: com.example.app, PID: 11692
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.AlarmActivity}:
android.view.InflateException: Binary XML file line #27: Attempt to
invoke virtual method 'boolean
java.lang.String.equals(java.lang.Object)' on a null object reference
Here is my code.
Intent i = new Intent(context, AlarmActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
From code above, Using debugger, I checked AlarmActivity.class and context is not null.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm);
...
}
But, savedInstanceState in AlarmActivity.java is null.
MainActivity.java
public class MainActivity extends AppCompatActivity implements ServiceCallbacks {
...
public void setAlarm (String[] times) {
int timesLen = times.length;
for (int i = 0 ; i < timesLen ; i++) {
if (times[i] != null) {
"2019-11-05 20:24:00";
int year = Integer.parseInt(times[i].substring(0, 4));
int month = Integer.parseInt(times[i].substring(5, 7)) - 1;
int date = Integer.parseInt(times[i].substring(8, 10));
int hour = Integer.parseInt(times[i].substring(11, 13));
int minute = Integer.parseInt(times[i].substring(14, 16));
int second = Integer.parseInt(times[i].substring(17, 19));
Calendar mCalendar = Calendar.getInstance();
mCalendar.set(Calendar.YEAR, year);
mCalendar.set(Calendar.MONTH, month);
mCalendar.set(Calendar.DATE, date);
mCalendar.set(Calendar.HOUR_OF_DAY, hour);
mCalendar.set(Calendar.MINUTE, minute);
mCalendar.set(Calendar.SECOND, second);
intent = new Intent(MainActivity.this, AlarmReceiver.class);
intent.putExtra("state", "on");
intent.putExtra("time", mCalendar);
intent.putExtra("id", i);
pendingIntent = PendingIntent.getBroadcast(MainActivity.this, i, intent, 0);
alarmManager.set(AlarmManager.RTC_WAKEUP, mCalendar.getTimeInMillis(), pendingIntent);
Log.d("LOGGING", "Alarm added: " + times[i]);
}
}
Toast.makeText(MainActivity.this, "Alarm added.", Toast.LENGTH_SHORT);
}
...
}
AlarmReceiver.java
...
public class AlarmReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Log.d("LOGGING", "AlarmReceiver");
Intent sIntent = new Intent(context, AlarmService.class);
sIntent.putExtra("state", intent.getStringExtra("state"));
sIntent.putExtra("time", intent.getSerializableExtra("time"));
sIntent.putExtra("id", intent.getStringExtra("id"));
Intent i = new Intent(context, AlarmActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(sIntent);
}
else {
context.startService(sIntent);
}
}
}
...
// activity_alarm.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AlarmActivity"
android:background="#CC000000">
<RelativeLayout
android:id="#+id/alarm-main-box"
android:layout_width="300dp"
android:layout_height="300dp"
android:background="#drawable/layout_bg"
android:layout_centerInParent="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="76.5dp"
android:text="nolvadex"
android:textSize="20dp"
android:textColor="#707070"
android:gravity="center"/>
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#drawable/textlines"
android:layout_marginRight="15.5dp"
android:layout_marginLeft="15.5dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="76.5dp"
android:text="femara"
android:textSize="20dp"
android:textColor="#707070"
android:gravity="center"/>
</LinearLayout>
<RelativeLayout
android:layout_width="64dp"
android:layout_height="90dp"
android:background="#drawable/layout_bg_gray_circle"
android:paddingBottom="10dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
</RelativeLayout>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:background="#drawable/layout_bg_pink">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="AM 8:00"
android:textSize="25dp"
android:textColor="#ffffff"
android:textAlignment="center"
android:gravity="center"
android:lineHeight="60dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="72dp"
android:layout_alignParentBottom="true"
android:background="#drawable/layout_bg_gray">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_alignParentBottom="true"
android:id="#+id/button-area">
<RelativeLayout
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true">
<ImageButton
android:id="#+id/center_button"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="#drawable/layout_round_center_button"
android:gravity="center_vertical|center_horizontal"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:elevation="2dp"
android:translationZ="2dp"
android:stateListAnimator="#null"
android:textColor="#fff"
android:src="#drawable/button_check"
android:adjustViewBounds="true"
android:scaleType="centerInside"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="all"
android:textSize="12dp"
android:textColor="#F48999"
android:layout_marginTop="11dp"
android:gravity="center"
android:layout_below="#+id/center_button"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="83dp"
android:layout_height="match_parent"
android:layout_centerVertical="true">
<ImageButton
android:id="#+id/left_button"
android:layout_width="37dp"
android:layout_height="37dp"
android:gravity="center_vertical|center_horizontal"
android:background="#drawable/layout_round_left_button"
android:layout_marginTop="30dp"
android:layout_marginLeft="33dp"
android:textColor="#fff"
android:src="#drawable/button_x"
android:adjustViewBounds="true"
android:scaleType="centerInside"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="next"
android:textSize="12dp"
android:layout_marginLeft="28dp"
android:layout_marginTop="2dp"
android:layout_below="#+id/left_button"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="83dp"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_alignParentRight="true">
<ImageButton
android:id="#+id/right_button"
android:layout_width="37dp"
android:layout_height="37dp"
android:gravity="center_vertical|center_horizontal"
android:background="#drawable/layout_round_right_button"
android:layout_marginTop="30dp"
android:layout_marginLeft="13dp"
android:textColor="#fff"
android:src="#drawable/button_clock"
android:adjustViewBounds="true"
android:scaleType="centerInside"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="re"
android:textSize="12dp"
android:layout_marginLeft="9dp"
android:layout_marginTop="2dp"
android:layout_below="#+id/right_button"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".AlarmActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".AlarmReceiver"
android:enabled="true"
android:exported="false" />
<service
android:name=".AlarmService"
android:enabled="true" />
</application>
</manifest>
I want to display AlarmActivity.
But this error occurs. please somebody help me.
I found the answer!!!!!!!!!
yeaaaaaaaaaaaaaaaaagghhhfbawjhefbwje!!!!!
I edited
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#drawable/textlines"
android:layout_marginRight="15.5dp"
android:layout_marginLeft="15.5dp"/>
to
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#drawable/textlines"
android:layout_marginRight="15.5dp"
android:layout_marginLeft="15.5dp"/>
view -> View
It works!

Trying to code an android app through eclipse to register bluetooth proximity, crashing on startup

I am writing an app that will eventually use Bluetooth to get a value for two devices' proximity to one another. I am currently trying to use buttons and onClick/onclicklistener etc to bring switch screens from the main UI to a log in or sign up page. Now my app is forcing close on start up and I'm not sure why. Thanks for any help!!
MainActivity:
package com.example.chirp;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter() ;
String status; {
if (bluetooth != null)
{
if (bluetooth.isEnabled())
{
String mydeviceaddress = bluetooth.getAddress();
String mydevicename = bluetooth.getName();
status = mydevicename + ":" + mydeviceaddress;
}
else
{
status = "Bluetooth is not Enabled.";
}
}
Toast.makeText(this, status, Toast.LENGTH_LONG).show();
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button loginbutton = (Button) findViewById(R.id.button1);
loginbutton.setOnClickListener(new OnClickListener(){
public void onClick(View v){
setContentView(R.layout.loginscreen);
}
});
}
#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;
}
public void newMessage(View v){
Intent intent = new Intent(this,loginscreen.class);
startActivity(intent);
}
}
activity_main.xml
<LinearLayout 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:orientation="vertical"
android:background="#7FFFD4"
android:padding="20dp"
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" >
<!-- <public void loginhere(View view) {
android:
}/>-->
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:text="#string/hello_world"
android:textSize="50sp"
android:typeface="serif" />
<SeekBar
android:id="#+id/seekBar1"
android:layout_marginTop="100dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32sp"
android:layout_gravity="center_horizontal"
android:text="Slide to Quick Find"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/button2"
android:layout_width="396dp"
android:layout_height="100dp"
android:layout_marginLeft="75dp"
android:layout_marginTop="300dp"
android:textSize="50sp"
android:text="Sign Up" />
<Button
android:id="#+id/button1"
android:layout_width="396dp"
android:layout_height="100dp"
android:layout_marginLeft="75dp"
android:layout_marginTop="50dp"
android:textSize="50sp"
android:onClick="onclick"
android:text="Log In" />
</LinearLayout>
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.chirp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"
android:requiresSmallestWidthDp="320"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.chirp.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="com.example.chirp.loginscreen"
android:label="CHIRP"
/>
</application>
</manifest>
loginscreen.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:background="#7FFFD4"
android:padding="20dp"
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=".login" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" >
<requestFocus />
</EditText>
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Username" />
/
</LinearLayout>
Move this code inside your onCreate method:
if (bluetooth != null) {
if (bluetooth.isEnabled()) {
String mydeviceaddress = bluetooth.getAddress();
String mydevicename = bluetooth.getName();
status = mydevicename + ":" + mydeviceaddress;
} else {
status = "Bluetooth is not Enabled.";
}
//etc...
Currently this code block is outside of any method of your activity and that is for sure not what you want to have.

Unfortunately my app has stopped working

Here is my login activity class where i want to do login after login it show the map but when i run the app it show unfortunately stopped login
loginActivity.java
package com.ivb.login;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class LoginActivity extends Activity{
EditText edtemail,edtPassword;
Button btnLogin;
String strUsername,strPassword;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.login);
edtemail = (EditText)this.findViewById(R.id.edt_email);
edtPassword = (EditText)this.findViewById(R.id.edt_passwrd);
btnLogin = (Button)this.findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
strUsername = edtemail.getText().toString().trim();
strPassword = edtPassword.getText().toString().trim();
if(strUsername.equals("needin#gmail.com") && strPassword.equals("needin123"))
startActivity(new Intent(LoginActivity.this,LoginSuccess.class).putExtra("usr",(CharSequence)strUsername));
else
Toast.makeText(LoginActivity.this,"Invalid UserName or Password", Toast.LENGTH_LONG).show();
}
});
TextView registerScreen = (TextView) findViewById(R.id.link_to_register);
// Listening to register new account link
registerScreen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Switching to Register screen
Intent i = new Intent(getApplicationContext(), RegisterActivity.class);
startActivity(i);
}
});
}
}
loginsuccess.java
package com.ivb.login;
import javax.security.auth.PrivateCredentialPermission;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;
import android.widget.Toast;
public class LoginSuccess extends Activity {
private GoogleMap googleMap;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.second);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
Intent in = getIntent();
if (in.getCharSequenceExtra("usr") != null) {
final TextView setmsg = (TextView)findViewById(R.id.showmsg);
setmsg.setText("Welcome \n "+in.getCharSequenceExtra("usr"));
}
}
private void initilizeMap() {
if (googleMap == null) {
googleMap =((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
protected void onResume() {
super.onResume();
initilizeMap();
}
}
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ivb.login"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.ivb.login.permission.MAPS_RECEIVE"
android:protectionLevel="signature"></permission>
<uses-permission android:name="com.ivb.login.permission.MAPS_RECEIVE"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.ivb.login.LoginActivity"
android:label="#string/app_name"
android:screenOrientation="sensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.ivb.login.RegisterActivity"
android:label="Register New Account"></activity>
<activity android:name="com.ivb.login.LoginSuccess"></activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyC-2jAJ7MEkho_gJv7KLeb-tHrU2zHDUQU" />
<uses-library android:name="com.google.android.maps"/>
</application>
</manifest>
second.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=".LoginSuccess" >
<LinearLayout android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#layout/header_gradient"
android:paddingTop="5dip"
android:paddingBottom="5dip" >
<ImageView android:src="#drawable/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"/>
</LinearLayout>
<TextView
android:id="#+id/showmsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Welcome"
android:textSize="20dip" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TextView>
</RelativeLayout>
login.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<LinearLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#layout/header_gradient" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/header"
android:orientation="vertical"
android:padding="10dip" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:src="#drawable/logo1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Email"
android:textColor="#372c24" />
<EditText
android:id="#+id/edt_email"
android:layout_width="209dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="20dip"
android:layout_marginTop="5dip"
android:ems="10"
android:hint="Enter Email Address"
android:inputType="textEmailAddress"
android:singleLine="true"
android:typeface="normal" >
<requestFocus />
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Password"
android:textColor="#372c24" />
<EditText
android:id="#+id/edt_passwrd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dip"
android:ems="10"
android:hint="Enter password"
android:inputType="textPassword"
android:password="true"
android:singleLine="true"
android:typeface="normal" />
<Button
android:id="#+id/btnLogin"
android:layout_width="133dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_marginTop="10dip"
android:background="#acd28a"
android:clickable="true"
android:gravity="center"
android:paddingLeft="15dip"
android:text="Login" />
<TextView
android:id="#+id/link_to_register"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dip"
android:layout_marginTop="40dip"
android:gravity="center"
android:text="Need an account?sign up"
android:textColor="#0b84aa"
android:textSize="20dip" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
Change from
<TextView
android:id="#+id/showmsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Welcome"
android:textSize="20dip" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TextView>
to
<TextView
android:id="#+id/showmsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Welcome"
android:textSize="20dip" >
</TextView>
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
this is because your < /TextView> was closed after fragment class so you got this error.
Also change here
startActivity(new Intent(LoginActivity.this,LoginSuccess.class).putExtra("usr",strUsername));
and also in your LoginSuccess Activity
Intent in = getIntent();
if (in.getStringExtra("usr") != null) {
final TextView setmsg = (TextView)findViewById(R.id.showmsg);
setmsg.setText("Welcome \n "+in.getStringExtra("usr"));
}
That means you have to declare this part in your manifest file...
<uses-feature android:glEsVersion="0x00020000" android:required="true/>
and must use latest updated Google Play Service.

Android app crashes upon startup

I am new to programming and after a while I finally fixed all my errors but now the app crashes on startup! I have not written all of this code by myself but I have edited it. Also when I still received errors the app could start (but not work obviously).
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tk.iWeld.iweld"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="22" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="tk.iWeld.iweld.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>
Activity_Main
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/RelativeLayout1"
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" >
<EditText
android:id="#+id/editText2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText2"
android:layout_alignBottom="#+id/editText2"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:ems="10"
android:hint="Text2"
android:inputType="number" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText2"
android:layout_centerHorizontal="true"
android:text="X"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_orange_dark" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editText2"
android:layout_centerHorizontal="true"
android:text="_________________________"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_orange_dark" />
<EditText
android:id="#+id/Text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView2"
android:layout_centerHorizontal="true"
android:ems="10"
android:hint="Text3"
android:inputType="number" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/Text3"
android:layout_marginTop="22dp"
android:text="="
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/holo_orange_dark"
android:textColorHint="#android:color/holo_orange_dark"
android:textSize="30sp" />
<TextView
android:id="#+id/textRes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView3"
android:layout_alignBottom="#+id/textView3"
android:layout_alignParentRight="true"
android:clickable="false"
android:longClickable="false"
android:text="Result"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/resultbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_alignTop="#+id/textView3"
android:text="Result" />
<EditText
android:id="#+id/editText1"
android:layout_width="89dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView1"
android:layout_alignLeft="#+id/textView2"
android:ems="10"
android:hint="Text1"
android:inputType="number" />
And the MainActivity
package tk.iWeld.iweld;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.menu.main);
}
public void calculateClickHandler(View view) {
// make sure we handle the click of the calculator button
if (view.getId() == R.id.resultbutton) {
// get the references to the widgets
EditText text1Text = (EditText)findViewById(R.id.editText1);
EditText text2Text = (EditText)findViewById(R.id.editText2);
EditText text3Text = (EditText)findViewById(R.id.Text3);
TextView resultText = (TextView)findViewById(R.id.textRes);
// get the users values from the widget references
float text1 = Float.parseFloat(text1Text.getText().toString());
float text2 = Float.parseFloat(text2Text.getText().toString());
float text3 = Float.parseFloat(text3Text.getText().toString());
// calculate the result value
float totalresult = calculateRESULT(text1, text2, text3);
// now set the value in the result text
resultText.setText("" + totalresult);
}
}
// the formula to calculate the result index
private float calculateRESULT (float text1, float text2, float text3) {
return (float) (text1 * text2 / text3);
}
}
There is a mistake in the second line in onCreate():
setContentView(R.menu.main);
You cannot set a menu as view. If you want to use the main layout, use this:
setContentView(R.layout.main);
This...
android:targetSdkVersion="22" />
is SCIENCE FICTION!
The maximum API level today is 19

Cannot run Eclipse / Android SDK Project - Errors of Unknown Origin

All the files look fine to me - anyone have any ideas/suggestions?
Thanks in advance!
Amani Swann
ERRORS:
Description Resource Path Location Type
Content is not allowed in trailing section. strings.xml /Linking Manager/res/values line 7 Android XML Format Problem
invalid resource directory name AndroidManifest.xml /Linking Manager/bin/res line 1 Android AAPT Problem
error: Error parsing XML: not well-formed (invalid token) strings.xml /Linking Manager/res/values line 7 Android AAPT Problem
Error generating final archive: java.io.FileNotFoundException: C:\Users\User\Desktop\Android Backups\3.1.2013 #1111pm\MyAndroidApp\bin\resources.ap_ does not exist Linking Manager Unknown Android Packaging Problem
main.xml file:
<?xml version="1.0" encoding="utf-8"?>
main2.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:id="#+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:textAppearance="?android:textAppearanceLarge" android:id="#+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="User Settings:" />
<TextView android:textAppearance="?android:textAppearanceLarge" android:id="#+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
<TextView android:textAppearance="?android:textAppearanceMedium" android:id="#+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Data Limit" />
<TextView android:textAppearance="?android:textAppearanceSmall" android:id="#+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
<SeekBar android:id="#+id/seekBar1" android:layout_width="fill_parent" android:layout_height="wrap_content" />
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:gravity="left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="10MB" android:layout_weight="1.0" />
<TextView android:gravity="right" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Unlimited Data" android:layout_weight="1.0" />
</LinearLayout>
<TextView android:textAppearance="?android:textAppearanceSmall" android:id="#+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
<TextView android:textAppearance="?android:textAppearanceMedium" android:id="#+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Bandwidth Limit" />
<TextView android:textAppearance="?android:textAppearanceSmall" android:id="#+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
<SeekBar android:id="#+id/seekBar1" android:layout_width="fill_parent" android:layout_height="wrap_content" />
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:gravity="left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="10kbs" android:layout_weight="1.0" />
<TextView android:gravity="right" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Unlimited Bandwidth" android:layout_weight="1.0" />
</LinearLayout>
<TextView android:textAppearance="?android:textAppearanceSmall" android:id="#+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:textAppearance="?android:textAppearanceMedium" android:id="#+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="WiFi Time Limit" />
<TextView android:textAppearance="?android:textAppearanceSmall" android:id="#+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
<TimePicker android:id="#+id/timePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="50.0dip" android:layout_weight="1.0" />
<TextView android:textAppearance="?android:textAppearanceSmall" android:id="#+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
<EditText android:id="#+id/editText1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Blocked Sites - [ex: www.xxx.com]" android:ems="10" />
</LinearLayout>
AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mkyong.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".SplashScreen"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".main2" >
</activity>
<activity android:name=".home" >
</activity>
<activity android:name=".App2Activity" >
</activity>
<activity
android:name=".AppActivity"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
AppActivity.java (primary java file)
package com.mkyong.android;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.content.Intent;
public class AppActivity extends Activity {
final Context context = this;
private Button button;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.button1);
// add button listener
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("Settings Menu");
// set dialog message
alertDialogBuilder
.setMessage("Link or Delete?")
.setCancelable(false)
.setPositiveButton("Link",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
//start new activity
Intent intentApp2Activity = new Intent(AppActivity.this, App2Activity.class);
startActivity(intentApp2Activity);
// if this button is clicked, close
// current activity
AppActivity.this.finish();
}
})
.setNegativeButton("Delete",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
});
}}
App2Activity.java
package com.mkyong.android;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
public class App2Activity extends Activity {
Button button;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
}
}
Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Linking Manager</string>
<string name="button1">Button1</string>
<string name="button2">Button2</string>
<string name="button3">Button3</string>
</resources>
ERRORS: (shown above at the top of this thread)
All the files look fine to me - anyone have any ideas/suggestions?
Thanks in advance!
Amani Swann
Try this.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:textAppearance="?android:textAppearanceLarge" android:id="#+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="NFC Linking Manager" />
<Button android:id="#+id/button1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Linksys Router (Home)" android:onClick="onPopupBtClick" />
<Button android:id="#+id/Button2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Netgear Router (Office)" />
<Button android:id="#+id/Button3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Cisco Router (Office)" />
</LinearLayout>
I edited your layout like android:id="#+id/Button3" in every components
Do same for main2.xml

Categories