getIntent() not capturing data properly - android

I am passing row id with the help of intent. The calling method being a custom adapter -
holder.text.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getContext(), "TEXT CLICKED" + pos , Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context,ReminderModificationActivity.class);
long longPos = (long)pos;
intent.putExtra(TasksDBAdapter.KEY_ROWID, pos);
Log.i(TAG, "row clickd --> " + longPos);
((Activity) context).startActivityForResult(intent, ACTIVITY_EDIT);
}
});
OnCreate() method of ReminderModificationActivity try to retrieve the data.Code -
protected void onCreate(Bundle savedInstanceState){
dbHelper = new TasksDBAdapter(this);
//set current theme
settingsDBAdapter = new SettingsDBAdapter(this);
settingsDBAdapter.open();
setSettingsTheme();
setContentView(R.layout.reminder_modify);
mCalendar = Calendar.getInstance();
Log.i(getLocalClassName(), "VALUE of Button--->" + findViewById(R.id.SetDateButtonId));
mDateButton = (Button) findViewById(R.id.SetDateButtonId);
mTimeButton = (Button) findViewById(R.id.SetTimeButtonId);
mConfirmButton = (Button) findViewById(R.id.SaveButtonId);
mTitleText = (EditText) findViewById(R.id.TitleEditTextId);
mBodyText = (EditText) findViewById(R.id.DescriptionEditTextId);
mRowId = savedInstanceState != null ? savedInstanceState.getLong(TasksDBAdapter.KEY_ROWID) : null ;
registerButtonListenersAndSetDefaultText();
Log.i(TAG, "getIntent-->" + getIntent() + mRowId);
//code to check what row id have been passed
if(getIntent() != null) {
---->>>MAIN CODE
Log.i(TAG, "mRowId in getintent-->" + mRowId + "row id passed-->" + getIntent().getLongExtra(TasksDBAdapter.KEY_ROWID, -1));
mRowId = getIntent().getLongExtra(TasksDBAdapter.KEY_ROWID, -1);
// Do stuff with the row id here
if(mRowId != -1){
//code if RowId valid
}
}
super.onCreate(savedInstanceState);
Log.i(TAG, "mROwId in onCreate ReminderNotification again-->" + mRowId);
}
line marked as MAIN CODE captures the intent data but Log.i gives value of
getIntent().getLongExtra(TasksDBAdapter.KEY_ROWID, -1))
as -1.Can sumone please help me out on this.Thanks in advance,Ray

Seeing as you cast pos to longPos, you should be using longPos in your intent extra, but you use pos.
if you were to change your code to:
Intent intent = new Intent(context,ReminderModificationActivity.class);
long longPos = (long)pos;
intent.putExtra(TasksDBAdapter.KEY_ROWID, longPos); //<< changed to longPos
It should work

Related

Sending integers via Intent method

I have seen a decent amount of methods to add a numerical value to an int integer value using intent(). Mine however is not working so well. Does anyone have any advice? I am sending an integer value, via a button, from a separate activity using theintent() method. This value should add 1 to the activity when the button is pressed. Here is what I have so far:
public class GameEmulator extends Activity{
//Creating two static values to pass strings from SelectPlayer classes
public final static String value = "EMPTY_VALUE";
public final static String value2 = "EMPTY_VALUE2";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout);
//Button created to go back to AddPlayer activity
Button addplayer1 = findViewById(R.id.button9);
addplayer1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(GameEmulator.this, AddPlayer.class);
startActivity(i);
}
});
Button viewScores = findViewById(R.id.viewScore);
viewScores.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(GameEmulator.this, MainActivity.class);
startActivity(intent);
}
});
//Button for player one winning
Button winButtonOne = findViewById(R.id.button7);
winButtonOne.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int scored = 1;
Intent intent = new Intent(GameEmulator.this, Scoreboard.class);
intent.putExtra("MY_KEY", scored);
startActivity(intent);
}
});
TextView textView = findViewById(R.id.name1);
TextView textview2 = findViewById(R.id.name2);
//setting value retrieved from SleectPlayer and Displaying it in textView
Intent intent = getIntent();
String extra = intent.getStringExtra(value);
textView.setText(extra);
//setting value retrieved from SleectPlayer2 and Displaying it in textView2
Intent in = getIntent();
String extra1 = in.getStringExtra(value2);
textview2.setText(extra1);
}
}
public class Scoreboard extends Activity{
public static ArrayAdapter<String> adapter2;
public static ArrayAdapter<String> adapter3;
public static ArrayList<String> list2 = new ArrayList<>();
public static ArrayList<String> list3 = new ArrayList<>();
ListView selectView3;
ListView selectView4;
public static int losses1 = 0;
public static int ties1 = 0;
public static int losses2 = 0;
public static int ties2 = 0;
public final static String value2 = "EMPTY_VALUE2";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scoreboard);
selectView3 = findViewById(R.id.selectview3);
selectView3.setVisibility(View.VISIBLE);
selectView4 = findViewById(R.id.selectview4);
selectView4.setVisibility(View.VISIBLE);
//Using adapter for ListView menu
adapter2 = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, list2);
selectView3.setAdapter(adapter2);
//Using intent to retrieve string from AddPlayer Activity
Intent i = getIntent();
int score = getIntent().getIntExtra("MY_KEY", 1);
String data = i.getStringExtra("text_key");
if(data != null){
list2.add("Player 1"+"\n"+"Name: "+data+"\n"+"Wins: "+ score +"\n"+"Losses: "+ losses1+"\n"+"Ties: "+ ties1);
}
if(data != ""){
changeList();
}
adapter3 = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, list3);
selectView4.setAdapter(adapter3);
Intent intent = getIntent();
String extra= intent.getStringExtra(value2);
if(extra != null) {
list3.add("Player 2" + "\n" + "Name: " + extra + "\n" + "Wins: " + score + "\n" + "Losses: " + losses2 + "\n" + "Ties: " + ties2);
}
if(data != ""){
changeList();
}
}
public void changeList()
{
adapter2.notifyDataSetChanged();
}
}
This line:
String data = i.getStringExtra("text_key");
makes data = null because you did not put in the original intent an extra value with key "text_key"
So this code:
list2.add("Player 1"+"\n"+"Name: "+data+"\n"+"Wins: "+ score +"\n"+"Losses: "+ losses1+"\n"+"Ties: "+ ties1);
is never executed

How to bring forward a integer

This is activityresult1
Button buttonorder;
TextView textviewcard;
private static final int REQUEST_CODE = 10;
int[] image ={R.drawable.friednoodle, R.drawable.friedrice, R.drawable.steamfish,R.drawable.tehice};
String[] item = {"Fried Noodle", "Fried Rice", "Steam Fish","Iced Tea"};
String[] description = {"Classic Chinese stir fried noodle with prawn and Pork", "Special sauce Fried Rice using indian rice", "HongKong Style Steamed Fish ","HongKong classical iced tea"};
String[] cost={"6","5","25","2"};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activityresult1);
Bundle extras = getIntent().getExtras();
String strcardnumber = extras.getString("Card Number");
textviewcard = (TextView) findViewById(R.id.textviewcard);
textviewcard.setText("Welcome, " + strcardnumber + " !" + "\nPlease select the food you want ! : ");
itemList = new ArrayList<DataInfo>();
itemList.add(new DataInfo(item[0], image[0], description[0], cost[0]));
itemList.add(new DataInfo(item[1], image[1], description[1], cost[1]));
itemList.add(new DataInfo(item[2], image[2], description[2], cost[2]));
itemList.add(new DataInfo(item[3], image[3], description[3], cost[3]));
final MenuAdapter adapter = new MenuAdapter(this);
ListView listView = (ListView)findViewById(R.id.list);
LVAdapter lvAdapter = new LVAdapter(this, itemList);
//listView.setAdapter(lvAdapter);
listView.setAdapter(adapter);
for (int i = 0; i < item.length; i++) {
adapter.addData(String.valueOf(i), item[i], image[i], description[i], cost[i]);
}
buttonorder = (Button) findViewById(R.id.suborder);
buttonorder.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String[] a = adapter.getQuantity();
Toast.makeText(getApplicationContext(), "Noodle: " + a[0] + "\nRice: " + a[1] + "\nSteam fish: " + a[2] + "\nIced tea: " + a[3], Toast.LENGTH_LONG).show();
int sum = Integer.parseInt(adapter.getQuantity()[0])*Integer.parseInt(cost[0]) +
Integer.parseInt(adapter.getQuantity()[1])*Integer.parseInt(cost[1]) +
Integer.parseInt(adapter.getQuantity()[2])*Integer.parseInt(cost[2]) +
Integer.parseInt(adapter.getQuantity()[3])*Integer.parseInt(cost[3]);
Intent myIntent = new Intent(activityresult1.this, activityresult2.class);
myIntent.putExtra("sum",sum);
startActivity(myIntent);
Intent intent = new Intent(getApplicationContext(), activityresult2.class);
Bundle bundle = new Bundle();
bundle.putString("Noodle quantity", adapter.getQuantity()[0]);
bundle.putString("Rice quantity", adapter.getQuantity()[1]);
bundle.putString("Fish quantity", adapter.getQuantity()[2]);
bundle.putString("Iced tea", adapter.getQuantity()[3]);
bundle.putInt("sum", sum);
bundle.putBoolean("ANI", adapter.getItem(0).isAddInisCheck());//add noodle ingredients
bundle.putBoolean("ARI", adapter.getItem(1).isAddInisCheck()); // add rice ingredients
bundle.putBoolean("AFI", adapter.getItem(2).isAddInisCheck());// add fish ingredients
bundle.putBoolean("AIT", adapter.getItem(3).isAddInisCheck()); // add ice tea ingredients
intent.putExtras(bundle);
startActivityForResult(intent, REQUEST_CODE);
}
});
}
how do i sent the calculated sum from activityresult1 to activityresult2
static public String txtOrder ="";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activityresult2);
Bundle bundle = getIntent().getExtras();
String strfnq = bundle.getString("Noodle quantity");
String strfrq = bundle.getString("Rice quantity");
String strfsq = bundle.getString("Fish quantity");
String stricq = bundle.getString("Iced tea");
Integer strsum = bundle.getInt("sum");
boolean addNingc = bundle.getBoolean("ANI");
boolean addRingc = bundle.getBoolean("ARI");
boolean addFingc = bundle.getBoolean("AFI");
boolean addTingc = bundle.getBoolean("AIT");
// boolean addmoneyc = bundle.getBoolean("AMY");
Intent mIntent = getIntent();
int sum = mIntent.getIntExtra("sum",strsum);
TextView costtext = (TextView)findViewById(R.id.costtext);
costtext.setText(getIntent().getExtras().getString("sum"));
TextView foodorders = (TextView) findViewById(R.id.foodordershow);
foodorders.setText(getIntent().getExtras().getString("Quantity"));
String addNdlThing = "";
if (addNingc) {
addNdlThing = " with addition of ingredients";
}
String addRlThing = "";
if (addRingc) {
addRlThing = " with addition of ingredients";
}
String addSlThing = "";
if ( addFingc) {
addSlThing = " with addition of ingredients";
}
String addTeac = "";
if ( addTingc ) {
addTeac = " with addition of ingredients";
}
foodorders = (TextView) findViewById(R.id.foodordershow);
if(strfnq.equals("") && strfrq.equals("") && strfsq.equals("")&& stricq.equals("")){
txtOrder = "Sorry, You've not ordered any thing , please return to previous menu to order";
}else if (!strfnq.equals("") && !strfrq.equals("") && !strfsq.equals("")&& stricq.equals("")) {
txtOrder = "Thank you , You've ordered\n" + strfnq + " fried noodle" + addNdlThing +" and\n"+ strfrq
+ " fried rice" + addRlThing +" and\n" + strfsq + " Steam fish " + addSlThing + "and\n" + stricq + " Steam fish " + addTeac;
} else {
txtOrder = "Thank you , You've ordered\n";
if(!strfnq.equals("")){
txtOrder = txtOrder + strfnq + " fried noodle" + addNdlThing;
}
if(!strfrq.equals("")){
txtOrder = txtOrder + strfrq + " fried rice" + addRlThing;
}
if(!strfsq.equals("")){
txtOrder = txtOrder + strfsq + " Steam fish" + addSlThing;
}
if(!stricq.equals("")){
txtOrder = txtOrder + stricq + " Iced Tea"+ addTeac;
}
}
foodorders.setText(txtOrder);
}
i want to calculate the money spent in result1 and display it in result 2
i have tried using the method they written at the bottom but it dont work as i dont know what to fill in for some . please help me , i really need help on this , and i am typing alot to make the word count so i can post , as i have too much codes they say , and please stop disliking this post , dont be such persons , like this and it will be happy for both parties , asking question dont mean i am stupid
You can sent the value of the sum to the next activity and get it via Bundle in the other activity like this. Think that your are sending it to the activity B
Intent i= new Intent(this,B.class);
i.putExtra("sum",sum);
startActivity(i);
you can send the context to the activity B through either one of the following this,getActivity(),getApplicationContext()
Then inactivity B you can add these lines in onCreate() method, to get the passed content
Bundle MainActivityData= getIntent().getExtras();
int sum= MainActivityData.getString("sum");

Activity calling itself -: Shared Preferences being cleared on pressing back button

I am using the following activity that keeps on calling itself. Things are working fine when I go in the forward direction but as soon as I click the back button, the shared preferrences is cleared.
SharedPreferences userLocalDatabase;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_paper_dashboard);
userLocalDatabase = PreferenceManager.getDefaultSharedPreferences(this);
name = userLocalDatabase.getString("name", "");
subject = userLocalDatabase.getString("subject", "");
timeLeft = userLocalDatabase.getInt("timeLeft", -1);
quesNo = userLocalDatabase.getInt("quesNo", -1);
no_of_ques = userLocalDatabase.getInt("no_of_ques", -1);
score = userLocalDatabase.getInt("score", -1);
currentLine = quesNo+1;
Log.i("TAG2", "Krishna the score returned from Shared Preferences is -: " +score);
myQuesTitle = (TextView)findViewById(R.id.myQuesTitle);
myTimer = (TextView)findViewById(R.id.myTimer);
myQuestion = (TextView)findViewById(R.id.myQuestion);
myFinish = (ImageButton)findViewById(R.id.myFinish);
myPrevious = (ImageButton)findViewById(R.id.myPrevious);
myAnswer = (ImageButton)findViewById(R.id.myAnswer);
myHint = (ImageButton)findViewById(R.id.myHint);
myNext = (ImageButton)findViewById(R.id.myNext);
myAnswer1 = (CheckBox)findViewById(R.id.myAnswer1);
myAnswer2 = (CheckBox)findViewById(R.id.myAnswer2);
myAnswer3 = (CheckBox)findViewById(R.id.myAnswer3);
myAnswer4 = (CheckBox)findViewById(R.id.myAnswer4);
String line = setLayout(name, timeLeft, quesNo, no_of_ques);
Log.i("TAG2", "Krishna the line returned is -: " + line);
}
this is the method for calling -:
public void clickPrevious(View v){
calculateScore();
SharedPreferences.Editor spEditor = userLocalDatabase.edit();
spEditor.putString("name", name);
spEditor.putString("subject", subject);
spEditor.putInt("timeLeft", timeLeft);
spEditor.putInt("no_of_ques", no_of_ques);
spEditor.putInt("quesNo", 0);
spEditor.putInt("score", 0 );
spEditor.commit();
Log.i("TAG2", "Baladeva score is -: " + score);
finish();
startActivity(new Intent(paper_dashboard.this, paper_dashboard.class));
}
posting the Next method-:
public void clickNext(View v){
calculateScore();
SharedPreferences.Editor spEditor = userLocalDatabase.edit();
spEditor.putString("name", name);
spEditor.putString("subject", subject);
spEditor.putInt("timeLeft", timeLeft);
spEditor.putInt("no_of_ques", no_of_ques);
spEditor.putInt("quesNo", quesNo+1);
spEditor.putInt("score", score);
spEditor.commit();
Log.i("TAG2", "Baladeva score is -: " + score);
Intent intent = new Intent(new Intent(this, paper_dashboard.class));
//intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}

Variable Stays Null

I'm trying to pass a String between activities, From YtAdapter to Favorites.
YtAdapter:
mHolder.mVideoFavorite.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//////////////////////////////////////////////////////////////
// Need to send SearchResult result from here to favorites //
////////////////////////////////////////////////////////////
AppUtils.showToast(result.getSnippet().getTitle() + " Was added to favorites.");
Intent intent = new Intent(mActivity,Favorites.class);
String vidId,vidTitle,vidThumbnail;
vidId = result.getId().getVideoId(); //Video ID
vidTitle = result.getSnippet().getTitle(); //Video Title
vidThumbnail = result.getSnippet().getThumbnails().getMedium().getUrl(); //Video Thumbnail
intent.putExtra("id",vidId);
intent.putExtra("title",vidTitle);
intent.putExtra("thumbnail",vidThumbnail);
}
});
And try to get it in Favorites:
/*Getting video information from YtAdapter*/
vidID = getIntent().getStringExtra("id"); <--- Stays null
vidTitle = getIntent().getStringExtra("title"); <--- Stays null
vidThumbnail = getIntent().getStringExtra("thumbnail"); <--- Stays null
I'm accessing Favorties from 3rd activity, not straight from YtAdapter.
try this in your main class:
Intent i = new Intent(ListViewActivity.this, EditContact.class);
Bundle bundle = new Bundle();
bundle.putInt("index", itemId);
bundle.putBoolean("AddContact", false);
i.putExtras(bundle);
startActivity(i);
and you can get your data in the other class like this:
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
Int index = bundle.getInt("index");
Boolean bool = bundle.getBoolean("AddContact");
if (bool ) {
setTitle("Add Contact");
} else {
setTitle("Edit Contact");
}
I hope it will help.
you can force all of your parameter be a string value:
intent.putExtra("id",vidId +"");
intent.putExtra("title",vidTitle+"");
intent.putExtra("thumbnail",vidThumbnail+"");
probally they aren't and you are getting with "getStringExtra".
but the better options is you use te correct "getter" of extra.
---Edit---
you can check in your activity the keys and values this way:
for(String key : getIntent().getExtras().keySet()){
Log.d("TEST", "key: " + key);
Log.d("TEST", "value: " + getIntent().getExtras().get(key));
}

onCreate() method with if-else condition

I am calling an activity namely LoginActivity.java in which i am getting values using Intent, storing data to SQLite, fetching data from SQLite and given a small condition, condition looks like this:
if(txtEvent.getText().toString().equals("") && txtOperative.getText().toString().equals(""))
{
Intent intentCall = new Intent(LoginActivity.this, LicenseListActivity.class);
startActivity(intentCall);
}
Now, how App works:-
Splash Screen > LoginActivity (if txtEvent and txtOperative equals to null) then calling > LicenseListActivity > GetEventsActivity > GetOperativesActivity (passing some values mainly EVENT & OPERATIVE name) to LoginActivity (also storing to database - checked using SQLite DB Viewer)
So issue is, instead of calling LoginActivity.java its calling LicenseListActivity.java again, after GetOperativesActivity.java ?
GetOperativesActivity.java:-
// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
firstName = contactList.get(position).get(TAG_NAME);
Intent intent = new Intent(GetOperativesActivity.this, LoginActivity.class);
intent.putExtra("name", name);
intent.putExtra("deviceID", deviceID);
intent.putExtra("emailID", emailID);
intent.putExtra("firstName", firstName);
startActivity(intent);
}
});
LoginActivity.java:-
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_login);
btnLogout = (Button) findViewById(R.id.btnLogout);
btnCamera = (Button) findViewById(R.id.btnCamera);
btnGallery = (Button) findViewById(R.id.btnGallery);
txtDeviceID = (TextView) findViewById(R.id.txtDeviceID);
txtEmailID = (TextView) findViewById(R.id.txtEmailID);
txtEvent = (TextView) findViewById(R.id.txtEvent);
txtOperative = (TextView) findViewById(R.id.txtOperative);
txtEventOperator = (TextView) findViewById(R.id.txtEventOperator);
Intent intent = getIntent();
deviceID = intent.getStringExtra("deviceID");
emailID = intent.getStringExtra("emailID");
event = intent.getStringExtra("name");
operative = intent.getStringExtra("firstName");
txtDeviceID.setText(deviceID);
txtEmailID.setText(emailID);
txtEvent.setText(event);
txtOperative.setText(operative);
txtEventOperator.setText(event + " " + operative);
strEvent = txtEvent.getText().toString();
strOperative = txtOperative.getText().toString();
// Dialog
final AlertDialog.Builder adb = new AlertDialog.Builder(this);
AlertDialog ad = adb.create();
// new Class DB
final myDBClass myDb = new myDBClass(this);
// Save Data
long saveStatus = myDb.InsertData(
txtDeviceID.getText().toString(),
txtEmailID.getText().toString(),
txtEvent.getText().toString(),
txtOperative.getText().toString(),
txtEventOperator.getText().toString()
);
if(saveStatus <= 0)
{
ad.setMessage("Error!! ");
ad.show();
return;
}
// Show Data
String arrData[] = myDb.SelectData();
if(arrData != null)
{
txtDeviceID.setText(arrData[1]);
txtEmailID.setText(arrData[2]);
txtEvent.setText(arrData[3]);
txtOperative.setText(arrData[4]);
txtEventOperator.setText(arrData[5]);
}
if(txtEvent.getText().toString().equals("") && txtOperative.getText().toString().equals(""))
{
Intent intentCall = new Intent(LoginActivity.this, LicenseListActivity.class);
startActivity(intentCall);
}
}
If you have any question in your mind, please let me know ...
public class LoginActivity extends Activity{
static int counter = 0;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_login);
btnLogout = (Button) findViewById(R.id.btnLogout);
btnCamera = (Button) findViewById(R.id.btnCamera);
btnGallery = (Button) findViewById(R.id.btnGallery);
txtDeviceID = (TextView) findViewById(R.id.txtDeviceID);
txtEmailID = (TextView) findViewById(R.id.txtEmailID);
txtEvent = (TextView) findViewById(R.id.txtEvent);
txtOperative = (TextView) findViewById(R.id.txtOperative);
txtEventOperator = (TextView) findViewById(R.id.txtEventOperator);
Intent intent = getIntent();
deviceID = intent.getStringExtra("deviceID");
emailID = intent.getStringExtra("emailID");
event = intent.getStringExtra("name");
operative = intent.getStringExtra("firstName");
txtDeviceID.setText(deviceID);
txtEmailID.setText(emailID);
txtEvent.setText(event);
txtOperative.setText(operative);
txtEventOperator.setText(event + " " + operative);
strEvent = txtEvent.getText().toString();
strOperative = txtOperative.getText().toString();
// Dialog
final AlertDialog.Builder adb = new AlertDialog.Builder(this);
AlertDialog ad = adb.create();
// new Class DB
final myDBClass myDb = new myDBClass(this);
// Save Data
long saveStatus = myDb.InsertData(
txtDeviceID.getText().toString(),
txtEmailID.getText().toString(),
txtEvent.getText().toString(),
txtOperative.getText().toString(),
txtEventOperator.getText().toString()
);
if(saveStatus <= 0)
{
ad.setMessage("Error!! ");
ad.show();
return;
}
// Show Data
String arrData[] = myDb.SelectData();
if(arrData != null)
{
txtDeviceID.setText(arrData[1]);
txtEmailID.setText(arrData[2]);
txtEvent.setText(arrData[3]);
txtOperative.setText(arrData[4]);
txtEventOperator.setText(arrData[5]);
}
if(counter==0&&txtEvent.getText().toString().equals("") && txtOperative.getText().toString().equals(""))
{
counter++;
Intent intentCall = new Intent(LoginActivity.this, LicenseListActivity.class);
startActivity(intentCall);
}
}//end onCreate
}//end class

Categories

Resources