This Blog post have the complete Code for an Android Application about various activity opening from ia single screen
In this blog post you can get all information relatated activating new activity from previous activity with actual runnable code.
This code is part of Android application MVC Project of School ERP. If you are faminliar with java and also have some good hands on Anadroid then you can easilly understand the code and can use this code in your own project.
package com.example.sawan.onlineattendance;
import android.content.Intent;
import android.database.Cursor;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class HOD extends AppCompatActivity {
Button studentremark,
btn2,
notice,
drictorNotice,
hodNotice,
Defaulter,
Inforamtion,
teacherLogin,
teacherremak;
JSONParser jParser = new JSONParser();
JSONObject json;
String buttton;
static String button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hod);
btn2 = (Button) findViewById(R.id.sdudent_lecture);
btn2.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, Student_subject_setting.class);
startActivity(intent);
}
});
studentremark = (Button) findViewById(R.id.studentNotification);
studentremark.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HODStudentRemark.class);
startActivity(intent);
}
});
teacherremak = (Button) findViewById(R.id.HomeWork);
teacherremak.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HomeWork.class);
startActivity(intent);
}
});
teacherLogin = (Button) findViewById(R.id.TeacherLogin);
teacherLogin.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HODTeacherLogin.class);
startActivity(intent);
}
});
notice = (Button) findViewById(R.id.update);
notice.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HODStudentNotification.class);
startActivity(intent);
}
});
hodNotice = (Button) findViewById(R.id.TecherNotification);
hodNotice.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, HODStaffNotice.class);
startActivity(intent);
}
});
Defaulter = (Button) findViewById(R.id.DefaulterStudent);
Defaulter.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, DefaulterCutOf.class);
startActivity(intent);
}
});
Inforamtion = (Button) findViewById(R.id.StudentDetail);
Inforamtion.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
Intent intent = new Intent(HOD.this, DirectorStudentFinal.class);
startActivity(intent);
}
});
drictorNotice = (Button) findViewById(R.id.DirectorNotice);
drictorNotice.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View view) {
new Login().execute();
}
});
}
private class Login extends AsyncTask < String,
String,
String > {@SuppressWarnings("WrongThread")@Override
protected String doInBackground(String...strings) {
String table = Identification.TableName; {
String url_login2 = "http://192.168.43. 156:8081/OnlineAttendance/DirectorNoticeServlet";
List < NameValuePair > params_dizsweb = new ArrayList < NameValuePair > ();
params_dizsweb .add(new BasicNameValuePair("t", Identification.TableName));
params_dizsweb .add(new BasicNameValuePair("cutoff", "HODDrictor"));
params_dizsweb .add(new BasicNameValuePair("text", "faltu"));
json = jParser.makeHttpRequest(url_login2, "GET", params);
String s = null;
try {
if (json.getString("info").equals("success")) {
Identification.FacultyDrictorNotices = json.getString("name");
Intent login = new Intent(getApplicationContext(), HODDrictorNotice.class);
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(login);
}
else {
Intent login = new Intent(getApplicationContext(), Error.class);
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(login);
}
} catch(Exception e) {
e.printStackTrace();
}
}
return null;
}
}
}
No comments:
Post a Comment