unknown Exception android - android

This is my main file, which has image buttons, and it gives me an exception. When I click on courses image button, it just closes the application.
It works for rest of buttons (rest activities just consist a text view and button) whereas in courses view, I added 3 more buttons (before I added these 3 buttons, it used to work for switching between main and courses).
What i am trying to do is this:
Make 3 buttons in courses activity. They will navigate me to other views like "higher education" or "further education". In next views I will create a list which will display name of courses (like "CCNA" or "Health diploma"!). When the user clicks on course, it will display a picture and some text information about the course.
package com.NVT.android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
public class Main extends Activity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton CoursesButton = (ImageButton)findViewById(R.id.CoursesButton);
ImageButton ILoveNescotButton = (ImageButton)findViewById(R.id.ILoveNescotButton);
ImageButton CampusMapButton = (ImageButton)findViewById(R.id.CampusMapButton);
ImageButton GettingHereButton = (ImageButton)findViewById(R.id.GettingHereButton);
CoursesButton.setOnClickListener(new ImageButton.OnClickListener()
{
#Override
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), Courses.class);
startActivityForResult(myIntent, 0);
}
});
ILoveNescotButton.setOnClickListener(new ImageButton.OnClickListener()
{
#Override
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), ILoveNescot.class);
startActivityForResult(myIntent, 0);
}
});
CampusMapButton.setOnClickListener(new ImageButton.OnClickListener()
{
#Override
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), CampusMap.class);
startActivityForResult(myIntent, 0);
}
});
GettingHereButton.setOnClickListener(new ImageButton.OnClickListener()
{
#Override
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), GettingHere.class);
startActivityForResult(myIntent, 0);
}
});
}
}
Code for Courses View "Courses.java" is given below,,,,
package com.NVT.android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Courses extends Activity
{
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.courses);
Button ButtonFurtherEducation = (Button)findViewById(R.id.Button_Courses_FurtherEducation);
Button ButtonHigherEducation = (Button)findViewById(R.id.Button_Courses_HigherEducation);
Button ButtonEmployernTraining = (Button)findViewById(R.id.Button_Courses_EmployersnTraining);
Button next = (Button) findViewById(R.id.Button01);
ButtonFurtherEducation.setOnClickListener(new Button.OnClickListener()
{
#Override
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), FurtherEducationCourses.class);
startActivityForResult(myIntent, 0);
}
});
ButtonHigherEducation.setOnClickListener(new Button.OnClickListener()
{
#Override
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), HigherEducationCourses.class);
startActivityForResult(myIntent, 0);
}
});
ButtonEmployernTraining.setOnClickListener(new Button.OnClickListener()
{
#Override
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), EmployersTrainingCourses.class);
startActivityForResult(myIntent, 0);
}
});
next.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});
}
}
and code for the further Education Activity is given below,,,,
package com.NVT.android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class FurtherEducationCourses extends Activity
{
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.further_education);
Button next = (Button) findViewById(R.id.Button01);
next.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});
}
}
my Manifest coding as below
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.NVT.android"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Main"
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=".Courses">
</activity>
<activity android:name=".CampusMap">
</activity>
<activity android:name=".GettingHere">
</activity>
<activity android:name=".ILoveNescot">
</activity>
<activity android:name=".FurtherEducationCourses">
</activity>
<activity android:name=".HigherEducationCourses">
</activity>
<activity android:name=".EmployersTrainingCourses">
</activity>
</application>
<uses-sdk android:minSdkVersion="9" />
</manifest>

You will see in the logcat screen that the first line with class name from your application is 'Courses.java'. So, the error occurs there. In the logcat you will see NullPointerException at Courses.java line 63. In line 63 of Courses.java you have set the onclick listener for the next button. So, I think the next button stay null when this line executes. I think the main error is in line no 21
Button next = (Button) findViewById(R.id.Button01);
I think the id of the next button in the layout file (corses.xml) is not Button01. Please fix this thing then there will be no errors.
Just try it. :)

According to the logcat screenshot, your problem is that Button next is null, since it is a NullPointerException in line 63, which is when you call next.setOnClickListener, which means that R.id.Button01 is not in R.layout.courses, could you verify if this information is correct?

Related

Splash Screen only runs on first launch, and won't run on proceeding launches

I've created a splash screen and it runs as intended. However, once the app has launched once, and is launched again, the splash screen doesn't show. It only shows at first launch which is not how it's supposed to work. I don't know how to resolve this. The splash screen code is posted below.
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.content.Intent;
public class SplashScreenActivity extends AppCompatActivity {
private int SLEEP_TIMER = 5;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash_screen);
getSupportActionBar().hide();
LogoLauncher logoLauncher = new LogoLauncher();
logoLauncher.start();
}
private class LogoLauncher extends Thread{
public void run(){
try{
sleep(1000 * SLEEP_TIMER);
}catch(InterruptedException e){
e.printStackTrace();
}
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
startActivity(intent);
SplashScreenActivity.this.finish();
}
}
}
EDIT: I'm testing on my physical device in android studio. When I hit run and the app launches it works. If I quit the app and launch it again from my phone* It doesn't work
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jstudios.main">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="MainApp"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="MainApp"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
</activity>
</application>
</manifest>
edit
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.content.Intent;
import android.os.Handler;
public class SplashScreenActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
getSupportActionBar().hide();
Handler h =new Handler() ;
h.postDelayed(new Runnable() {
#Override
public void run() {
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
startActivity(intent);
SplashScreenActivity.this.finish();
}, 5000);
}
}
please use handler to trigger your startActivity
setContentView(R.layout.activity_splash_screen);
getSupportActionBar().hide();
Handler h =new Handler() ;
h.postDelayed(new Runnable() {
#Override
public void run() {
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
startActivity(intent);
SplashScreenActivity.this.finish();
}, 5000);
Or use Timer
new Timer().schedule(new TimerTask() {
#Override
public void run()
{
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
startActivity(intent);
SplashScreenActivity.this.finish()
}
}, 5000);
Sleeping the main thread to display a Splash screen is really a bad practice.
The Splash screen should be displayed only while the app is loading (not a fixed time) to your main activity.
I recommend this approach, I've been using it in my own apps:
https://www.bignerdranch.com/blog/splash-screens-the-right-way/

Android Studio change activity crash

Activity crash on mobile, but on simulator works, whats wrong? Can anyone help me please?
Its a simple app that show some button than when clicked show a image.
6 Activity
Main Activity
package com.example.mobilejoy.kids1;
import android.content.Intent;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Transições de Cena
ImageButton toolbar2 = (ImageButton) findViewById(R.id.toolbarIcon2);
toolbar2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(MainActivity.this,SecondActivity.class);
startActivity(myIntent);
finish();
}
});
ImageButton toolbar3 = (ImageButton) findViewById(R.id.toolbarIcon3);
toolbar3.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(MainActivity.this,ThirdActivity.class);
startActivity(myIntent);
finish();
}
});
ImageButton toolbar4 = (ImageButton) findViewById(R.id.toolbarIcon4);
toolbar4.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(MainActivity.this,FourthActivity.class);
startActivity(myIntent);
finish();
}
});
ImageButton toolbar5 = (ImageButton) findViewById(R.id.toolbarIcon5);
toolbar5.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(MainActivity.this,FifthActivity.class);
startActivity(myIntent);
finish();
}
});
ImageButton toolbar6 = (ImageButton) findViewById(R.id.toolbarIcon6);
toolbar6.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(MainActivity.this,SixthActivity.class);
startActivity(myIntent);
finish();
}
});
//Evento clicar botão executar audio
final MediaPlayer first121 = MediaPlayer.create(this, R.raw.first121);
ImageButton imageButton121 = (ImageButton) this.findViewById(R.id.imageButton121);
imageButton121.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
first121.start();
}
});
}
}
Second Activity
package com.example.mobilejoy.kids1;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageButton;
/**
* Created by mobilejoy on 9/13/16.
*/
public class SecondActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
//transição entre cenas
ImageButton toolbar1 = (ImageButton) findViewById(R.id.toolbarIcon1);
toolbar1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(SecondActivity.this,MainActivity.class);
startActivity(myIntent);
finish();
}
});
ImageButton toolbar3 = (ImageButton) findViewById(R.id.toolbarIcon3);
toolbar3.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(SecondActivity.this,ThirdActivity.class);
startActivity(myIntent);
finish();
}
});
ImageButton toolbar4 = (ImageButton) findViewById(R.id.toolbarIcon4);
toolbar4.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(SecondActivity.this,FourthActivity.class);
startActivity(myIntent);
finish();
}
});
ImageButton toolbar5 = (ImageButton) findViewById(R.id.toolbarIcon5);
toolbar5.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(SecondActivity.this,FifthActivity.class);
startActivity(myIntent);
finish();
}
});
ImageButton toolbar6 = (ImageButton) findViewById(R.id.toolbarIcon6);
toolbar6.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent = new Intent(SecondActivity.this,SixthActivity.class);
startActivity(myIntent);
finish();
}
});
}
}
and the XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mobilejoy.kids1">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.mobilejoy.kids1.SecondActivity"></activity>
<activity android:name="com.example.mobilejoy.kids1.ThirdActivity"></activity>
<activity android:name="com.example.mobilejoy.kids1.FourthActivity"></activity>
<activity android:name="com.example.mobilejoy.kids1.FifthActivity"></activity>
<activity android:name="com.example.mobilejoy.kids1.SixthActivity"></activity>
</application>
</manifest>
End.

Android Intent: “No Activity found to handle Intent” errors

No problems in first activity open on emulator but the problem is when press on the button it upon
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainlayoutActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlayout);
final Button man = (Button) findViewById(R.id.getDATA);
man.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MainlayoutActivity.this, second.class);
startActivityForResult(i, 77);
}
});
}
public void onActivityResult(int requstCode, int resultCode, Intent data) {
if ((requstCode == 77) && (resultCode == Activity.RESULT_OK)) {
String gett = data.getExtras().getString("TEXT value");
Toast.makeText(this, gett, Toast.LENGTH_LONG).show();
}
}
}
the problem is start second activity on emulator
public class second extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.seconlayout);
final Button btn = (Button) findViewById(R.id.GDATA);
final EditText ed = (EditText) findViewById(R.id.value);
btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
String word = ed.getText().toString();
Intent i = new Intent();
i.putExtra("TEXT value", word);
setResult(Activity.RESULT_OK, i);
finish();
}
});
}
}
And the manifest file
<? xml version = "1.0"encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.l9"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="com.example.l9.MainlayoutActivity"
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.l9.second">
<intent-filter>
<action android:name="net.abdullaheid.action.ToDATA"/>
<category android:name="android.intent.categor.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
Intent intent = new Intent();
This without parameters is useless if you dont want to transfer from this activity back. You need to create Intent with parameters
Intent(ThisActivity.this, WhereIWantToGoActivity.class) and then call startActivity(intent).
So, you got error, because your Intent() constructor is empty.

Only one of three buttons working

Hey I am trying to get different buttons to open up different pages in a android project but only on of the buttons is opening up a new page.
I am new to programming so my terminology may not be correct but I was following a youtube tutorial and it showed how to create a button and make it open up a new page. I tried to do this for multiple buttons but I think I am making the mistake in the main activity. Sorry if I haven't provided the write information to help me solve the problem.
package test.activity.today;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ActivityTutorialActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button next = (Button) findViewById(R.id.next_button);
next.setOnClickListener(new OnClickListener(){
public void onClick (View v){
Intent myIntent = new Intent(v.getContext(), NextActivity.class);
v.getContext().startActivity(myIntent);
}
});
}
public void onCreate1(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button next = (Button) findViewById(R.id.question_button);
next.setOnClickListener(new OnClickListener(){
public void onClick (View v){
Intent myIntent = new Intent(v.getContext(), Question.class);
v.getContext().startActivity(myIntent);
}
});
}
public void onCreate2(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button next = (Button) findViewById(R.id.owner_cost);
next.setOnClickListener(new OnClickListener(){
public void onClick (View v){
Intent myIntent = new Intent(v.getContext(), Owner.class);
v.getContext().startActivity(myIntent);
}
});
}
}
you should only have one onCreate() method.. check android activity's life cycle to understand it
package test.activity.today;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ActivityTutorialActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button next = (Button) findViewById(R.id.next_button);
next.setOnClickListener(new OnClickListener(){
public void onClick (View v){
Intent myIntent = new Intent(v.getContext(), NextActivity.class);
v.getContext().startActivity(myIntent);
}
});
Button question = (Button) findViewById(R.id.question_button);
question.setOnClickListener(new OnClickListener(){
public void onClick (View v){
Intent myIntent = new Intent(v.getContext(), Question.class);
v.getContext().startActivity(myIntent);
}
});
Button ownerCost = (Button) findViewById(R.id.owner_cost);
ownerCost.setOnClickListener(new OnClickListener(){
public void onClick (View v){
Intent myIntent = new Intent(v.getContext(), Owner.class);
v.getContext().startActivity(myIntent);
}
});
}
}
You are duplicating the onCreate() method... this method is called natively by Android and, thus, none of your other methods will get called (you'd have other problems if they were). To create more than one button, you need to add new buttons to your layout and then add them to onCreate().
There is another way to implement the onClick.
In your layout you can specify the function to call onClick
<ImageButton
android:id="#+id/imageButtonNext1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#color/back_color"
android:onClick="RegistraterCompanyOnClick"
android:src="#drawable/ic_next" />
Then in your activity you can filter which button by it's ID. See below.
public void RegistraterCompanyOnClick(View v){
switch(v.getId()){
case R.id.imageButtonNext1:
String cname = company.getText().toString();
if (cname.length()== 0){
message = getString(R.string.company_required);
ShowDialog(message);
}
else{
company_name = company.getText().toString();
VerifyClient(company_name);
}
break;
case R.id.imageButtonInfo1:
//message = getString(R.string.registration_info);
message = "Device ID:\n" + deviceID;
// TODO Auto-generated method stub
ShowDialog(message);
break;
case R.id.imageButtonHelp1:
message = getString(R.string.registration_contact);
// TODO Auto-generated method stub
ShowDialog(message);
break;
case R.id.imageButtonPrevious1:
Intent resultIntent = new Intent();
// TODO Auto-generated method stub
resultIntent.putExtra("company_name", company.getText().toString());
resultIntent.putExtra("company_id", companyID);
resultIntent.putExtra("location_name", location_name);
resultIntent.putExtra("location_id", locationID);
setResult(Activity.RESULT_CANCELED, resultIntent);
finish();
default:
break;
}
}

Displaying Another Screen Onclick in Android

package com.example.example;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
public class MainActivity extends Activity {
Button btn;
#Override
public void onCreate(Bundle savedInstanceState) {
this.setContentView(R.layout.activity_main);
this.btn = (Button)this.findViewById(R.id.button);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, profile.class);
startActivity(intent);
}
});
}
}
I don't get any errors however my program also dont run as I want. I am new in android and I want to change the screen after the button is clicked for that I am using two classes so in one class my program should invoke another one onclick. How can I do this ? My code is as above.
First remove this.setContentView(R.layout.activity_main); because you declared it twice . Then declare
btn = (Button)this.findViewById(R.id.button);
after
setContentView(R.layout.activity_main);
Declare your profile activity in manifest file.Check my code below.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button)this.findViewById(R.id.button);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, profile.class);
startActivity(intent);
}
});
1) your oncreate method should look like below one.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button)this.findViewById(R.id.button);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, profile.class);
startActivity(intent);
}
});
2) Add profile Activity into Manifest.
3) add logs in onClick method so you should know if it is getting called on not.
Happy coding!!

Categories

Resources