alright so im making an android app, and basically everything is working fine expect the whole part about changing the status textview everytime "moneynum" is increased by 100. Heres my code:
package life.project;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ViewFlipper;
public class LifeActivity extends Activity {
/** Called when the activity is first created. */
ViewFlipper views;
int lifestatus=0;
TextView status;
Button main;
Button work;
TextView timer;
int moneynum=0;
int test=0;
Button GasStation;
Button Walmart;
Button Business;
TextView Moneycount;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
main=(Button) findViewById(R.id.button9);
views=(ViewFlipper) findViewById(R.id.viewFlipper1);
GasStation=(Button) findViewById(R.id.button13);
Walmart=(Button) findViewById(R.id.button23);
Business=(Button) findViewById(R.id.button33);
Moneycount=(TextView) findViewById(R.id.textView);
timer=(TextView) findViewById(R.id.textView3);
status=(TextView) findViewById(R.id.textView4);
work=(Button) findViewById(R.id.button1);
new CountDownTimer(1200000, 60000) {
public void onTick(long millisUntilFinished) {
timer.setText("Minutes remaining: " + millisUntilFinished / 60000);
}
public void onFinish() {
onPause();{
Intent timerends=new Intent("com.life.project.timesup");
startActivity(timerends);
finish();
}
}
}.start();
main.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
views.showPrevious();
}
});
work.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
views.showNext();
}
});
GasStation.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
moneynum+=5;
Moneycount.setText("Money:$ "+moneynum+" .00");
if(moneynum==moneynum+100){
lifestatus+=1;
status.setText("Status: "+lifestatus);
}
}
});
Walmart.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
moneynum+=10;
Moneycount.setText("Money:$ "+moneynum+" .00");
if(moneynum==moneynum+100){
lifestatus+=1;
status.setText("Status: "+lifestatus);
}
}
});
Business.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
moneynum+=20;
Moneycount.setText("Money:$ "+moneynum+" .00");
if(moneynum==moneynum+100){
lifestatus+=1;
status.setText("Status: "+lifestatus);
}
}
});
}
}
and heres the part where its not working:
Moneycount.setText("Money:$ "+moneynum+" .00");
if(moneynum==moneynum+100){
lifestatus+=1;
status.setText("Status: "+lifestatus);
}
so everytime moneynum is increased by 100 i want lifestatus to increase by one and go through the rest of the code. But the if statement isnt executing when i run the program, and i think its because i have the arguments of the if statement wrong..can someone figure out i could make this work? sorry if this is confusing.
public .... LifeActivity
{
int moneySum = 100;
....
....
}
public void moneyCount()
{
if(moneynum>=moneySum) // Morethan incase your using looking for when moneynum passes 100 mark not when it equal exactly 100
{
lifestatus+=1;
status.setText("Status: "+lifestatus);
moneySum+=100;
}
}
public void onClick(View v) {
// TODO Auto-generated method stub
moneynum+=20;
Moneycount.setText("Money:$ "+moneynum+" .00");
moneyCount();
Related
I have tried searching for this topic but i didn't find anything that would help me, so here I am asking this.
I am a beginner so I don't understand a lot of terms and if you answer my question please try to use simple language so I could understand.
I have a condition in that the elements at same position of two lists are compared and if they aren't equal than it jumps to another activity:
if (randomColors.get(i) != userColors.get(i)) {
Intent i = new Intent( GameActivity.this, GameOverActivity.class);
startActivity(i);
}
and it displays an error in debugging that I cannot solve:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gabie212.simonsays/com.gabie212.simonsays.GameOverActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
Please help me, I am a beginner and I don't know what's wrong with my code because I have done exactly as they taught us in class...
Here is the complete code
I know its not the best but its a work in proggress
package com.gabie212.simonsays;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import java.util.ArrayList;
public class GameActivity extends AppCompatActivity implements
View.OnClickListener {
private int i = 0;
private Thread t = new Thread();
private Button greenButton;
private Button redButton;
private Button blueButton;
private Button yellowButton;
private Button startButton;
private ArrayList<Integer> randomColors = new ArrayList<Integer>();
private ArrayList<Integer> userColors = new ArrayList<Integer>();
private GameManger gm;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gm = new GameManger(this);
setContentView(R.layout.activity_game);
greenButton = (Button) findViewById(R.id.btnGreen);
redButton = (Button) findViewById(R.id.btnRed);
blueButton = (Button) findViewById(R.id.btnBlue);
yellowButton = (Button) findViewById(R.id.btnYellow);
startButton = (Button) findViewById(R.id.btnStart);
startButton.setOnClickListener(this);
greenButton.setOnClickListener(this);
redButton.setOnClickListener(this);
blueButton.setOnClickListener(this);
yellowButton.setOnClickListener(this);
}
#Override
public void onClick(View v) {
int num;
num= gm.getColor(4);
randomColors.add(num);
android.os.Handler handler = new android.os.Handler();
//TODO if the start button is pressed multiple times simultaneously it starts the lightup loop multiple times simultaneously
if (v.getId() == startButton.getId()) {
for (i = 0; i < randomColors.size(); i++) //light up loop
{
switch (randomColors.get(i)) {
case 1:
greenButton.setBackgroundResource(R.drawable.greenlightup);
handler.postDelayed(new Runnable()
{
#Override
public void run() {
// TODO Auto-generated method stub
greenButton.setBackgroundResource(R.drawable.green);
}
}, 2000);
break;
case 2:
redButton.setBackgroundResource(R.drawable.redlightup);
handler.postDelayed(new Runnable()
{
#Override
public void run() {
// TODO Auto-generated method stub
redButton.setBackgroundResource(R.drawable.red);
}
}, 2000);
break;
case 3:
blueButton.setBackgroundResource(R.drawable.bluelightup);
handler.postDelayed(new Runnable()
{
#Override
public void run() {
// TODO Auto-generated method stub
blueButton.setBackgroundResource(R.drawable.blue);
}
}, 2000);
break;
case 4:
yellowButton.setBackgroundResource(R.drawable.yellowlightup);
handler.postDelayed(new Runnable()
{
#Override
public void run() {
// TODO Auto-generated method stub
yellowButton.setBackgroundResource(R.drawable.yellow);
}
}, 2000);
break;
}
handler.postDelayed(new Runnable()
{
public void run() {
}
}, 2000);
}
for(i=0;i<randomColors.size();i++)
{
if(v.getId()==greenButton.getId())
{
userColors.add(1);
}
else
{
if(v.getId()==redButton.getId()){
userColors.add(2);
}
else
{
if(v.getId()==blueButton.getId())
{
userColors.add(3);
}
else
{
userColors.add(4);
}
}
}
}
for(i=0;i<randomColors.size();i++)
{
if(randomColors.get(i)!=userColors.get(i))
{
Intent i = new Intent( GameActivity.this, GameOverActivity.class);
startActivity(i);
}
}
}
}
}
by the its not a simple null pointer exception, at least i don't think so because there is nothing here to be null, there is only a simple intent in an if statement
here's the code for the game over activity
package com.gabie212.simonsays;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
public class GameOverActivity extends AppCompatActivity implements View.OnClickListener {
private Button againButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game_over);
againButton = (Button) findViewById(R.id.btnStart);
againButton.setOnClickListener(this);
}
#Override
public void onClick(View view) {
Intent in = new Intent(GameOverActivity.this, GameActivity.class);
startActivity(in);
}
}
Thanks in advance.
In your GameOverActivity, on this line:
againButton = (Button) findViewById(R.id.btnStart);
Your againButton is null as you are referencing btnStart from your main activity layout (activity_game.xml). This can't be found because your GameOverActivity is using activity_game_over.xml for its layout:
setContentView(R.layout.activity_game_over);
Any views need to be defined within the activity_game_over.xml file for them to be used by the activity. You need to reference the ID of the button as defined in layout/activity_game_over.xml
againButton = (Button) findViewById(R.id.btnAgain); // Or whatver you've named it
As for your specific question as to why the Intent is not working, the Intent itself is working fine, it's just that GameOverActivity cannot start up properly due to the above issue, and therefore your app crashes.
I want to create a sound by comparing longitude and latitude with a value when value is 0. I tried this with infinite loop without thread. But the program crashed. Then I tried with thread, but it also failed.
public class MainActivity extends Activity
{
Button start,exit;
GPSTracker gps;
MediaPlayer audio1;
Boolean button;
TextView txt1;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
start=(Button)findViewById(R.id.button1);
exit=(Button)findViewById(R.id.button2);
txt1=(TextView)findViewById(R.id.textView1);
audio1=MediaPlayer.create(MainActivity.this,R.raw.audio);
button=false;
start.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(button==true)
{
button=false;
start.setText("START");
txt1.setText("Press 'START' to start working");
audio1.pause();
}
else
{
button=true;
start.setText("STOP");
txt1.setText("Press 'STOP' to stop working");
gps= new GPSTracker(MainActivity.this);
if(gps.canGetLoc())
{
double latitude= gps.getLatitude();
double longitude=gps.getLongitude();
if(latitude!=0&&longitude!=0)
{
audio1.start();
}
else
Toast.makeText(getApplicationContext(), "Wait for some seconds...", Toast.LENGTH_SHORT).show();
}
else
{
gps.showSettingsAlert();
}
}
}
});
exit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
audio1.stop();
finish();
}
});
}
I want to use the Speech Recongnition to handle commands in my application. I know
at any given point in my application what the valid commands would be
at that point so would like to limit the results that the Speech Recongnition is
matched against.
I mean in my app .. The valid words are only numbers plus alphabets. I mean number like A13FG6 something like that.
I would
like to be able to restrict the Speech recongnition to only try and match against alphaNumeric
words.. Limiting the vocabularly would enhance its chance of success..
how could i modify the given code to fulfill my requirement
Thanks in advance..
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
private TextView mText;
private SpeechRecognizer sr;
private static final String TAG = "MyStt3Activity";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button speakButton = (Button) findViewById(R.id.btn_speak);
mText = (TextView) findViewById(R.id.textView1);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
getClass().getPackage().getName());
SpeechRecognizer recognizer = SpeechRecognizer
.createSpeechRecognizer(this.getApplicationContext());
RecognitionListener listener = new RecognitionListener() {
#Override
public void onResults(Bundle results) {
ArrayList<String> voiceResults = results
.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
if (voiceResults == null) {
Log.e(TAG, "No voice results");
} else {
Log.d(TAG, "Printing matches: ");
for (String match : voiceResults) {
Log.d(TAG, match);
mText.setText("results: " + match);
}
}
}
#Override
public void onReadyForSpeech(Bundle params) {
Log.d(TAG, "Ready for speech");
}
#Override
public void onError(int error) {
Log.d(TAG,
"Error listening for speech: " + error);
}
#Override
public void onBeginningOfSpeech() {
Log.d(TAG, "Speech starting");
}
#Override
public void onBufferReceived(byte[] buffer) {
// TODO Auto-generated method stub
}
#Override
public void onEndOfSpeech() {
// TODO Auto-generated method stub
}
#Override
public void onEvent(int eventType, Bundle params) {
// TODO Auto-generated method stub
}
#Override
public void onPartialResults(Bundle partialResults) {
// TODO Auto-generated method stub
}
#Override
public void onRmsChanged(float rmsdB) {
// TODO Auto-generated method stub
}
};
recognizer.setRecognitionListener(listener);
recognizer.startListening(intent);
/* speakButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
// intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
getClass().getPackage().getName());
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
sr.startListening(intent);
// startActivityForResult(intent, 1010);
Log.i("111111", "11111111");
}
});*/
}
}
You can not restrict recognition in Android Speech API, it doesn't support grammars. However, you can try CMUSphinx. See the example under link, you can define a grammar to use alpha digits only, it will work offline so the response will be very fast and you can tune accuracy for the best match too.
I am designing a calculator in android. If I do for example 5+5 and then hit =, I get 10. However, if I do 5+5+5 and then hit =, I still get 10. I want my calculator to handle multiple operands so that when I do 5+5+5 for example, I get 15 when I hit equals.
Here's what I have so far:
package edu.uwstout.pocketcalculator;
import java.text.DecimalFormat;
import java.util.ArrayList;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class Basic extends Activity {
private Button one, two, three, four,
five, six, seven, eight, nine, zero,
add, subtract, multiply, divide, decimal,
negative, enter, clear;
private TextView output;
double numberOne;
double numberTwo;
double total;
double plusMinus;
int plus;
int minus;
int multiply_counter;
int divide_counter;
int decimal_counter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_basic);
one = (Button) findViewById(R.id.b1);
one.setTextColor(Color.BLACK);
one.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "1");
}
});
two = (Button) findViewById(R.id.b2);
two.setTextColor(Color.BLACK);
two.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "2");
}
});
three = (Button) findViewById(R.id.b3);
three.setTextColor(Color.BLACK);
three.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "3");
}
});
four = (Button) findViewById(R.id.b4);
four.setTextColor(Color.BLACK);
four.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "4");
}
});
five = (Button) findViewById(R.id.b5);
five.setTextColor(Color.BLACK);
five.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "5");
}
});
six = (Button) findViewById(R.id.b6);
six.setTextColor(Color.BLACK);
six.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "6");
}
});
seven = (Button) findViewById(R.id.b7);
seven.setTextColor(Color.BLACK);
seven.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "7");
}
});
eight = (Button) findViewById(R.id.b8);
eight.setTextColor(Color.BLACK);
eight.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "8");
}
});
nine = (Button) findViewById(R.id.b9);
nine.setTextColor(Color.BLACK);
nine.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "9");
}
});
zero = (Button) findViewById(R.id.b0);
zero.setTextColor(Color.BLACK);
zero.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
output.setText(output.getText() + "9");
}
});
decimal = (Button) findViewById(R.id.bDot);
decimal.setTextColor(Color.BLACK);
decimal.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(decimal_counter == 0){
output.setText(output.getText() + ".");
}
decimal_counter = 1;
}
});
negative = (Button) findViewById(R.id.bNeg);
negative.setTextColor(Color.BLACK);
negative.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
plusMinus=(Double.parseDouble(String.valueOf(output.getText())));
plusMinus=plusMinus*(-1);
output.setText(String.valueOf(plusMinus));
}
});
add = (Button) findViewById(R.id.bPlus);
add.setTextColor(Color.BLACK);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
numberOne=(Double.parseDouble(String.valueOf(output.getText())));
plus = 1;
output.setText("");
decimal_counter=0;
}
});
subtract = (Button) findViewById(R.id.bMinus);
subtract.setTextColor(Color.BLACK);
subtract.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
numberOne=(Double.parseDouble(String.valueOf(output.getText())));
output.setText("");
minus=1;
decimal_counter=0;
}
});
multiply = (Button) findViewById(R.id.bTimes);
multiply.setTextColor(Color.BLACK);
multiply.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
numberOne=(Double.parseDouble(String.valueOf(output.getText())));
output.setText("");
multiply_counter=1;
decimal_counter=0;
}
});
divide = (Button) findViewById(R.id.bDivide);
divide.setTextColor(Color.BLACK);
divide.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
numberOne=(Double.parseDouble(String.valueOf(output.getText())));
output.setText("");
divide_counter=1;
decimal_counter=0;
}
});
enter = (Button) findViewById(R.id.bEnter);
enter.setTextColor(Color.BLACK);
enter.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
output.setText(String.valueOf(enter(numberOne)));
}
});
clear = (Button) findViewById(R.id.bClear);
clear.setTextColor(Color.BLACK);
clear.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
output.setText("");
decimal_counter=0;
}
});
output = (TextView) findViewById(R.id.bOutput);
registerForContextMenu(output);
}
public double enter(double numberOne){
numberTwo = (Double.parseDouble(String.valueOf(output.getText())));
if(plus>0){
total = numberOne + numberTwo;
numberOne = 0;
numberTwo = 0;
plus = 0;
return total;
}
if(minus>0){
total = numberOne - numberTwo;
numberOne = 0;
numberTwo = 0;
minus = 0;
return total;
}
if(multiply_counter>0){
total = numberOne * numberTwo;
numberOne = 0;
numberTwo = 0;
multiply_counter = 0;
return total;
}
if(divide_counter>0){
total = numberOne / numberTwo;
numberOne = 0;
numberTwo = 0;
divide_counter = 0;
return total;
}
return total;
}
}
it seems that you are replacing your numberOne every time when an operand is clicked...
so try to perform calculation after every operand click ... check if numberOne contains value and if it contains perform the operation and store the value to numberOne...
otherwise just put the value to numberOne without performing calculation..
I keep getting this errors related to Thread.stop() in splashscreen.java. I'm pretty new at it and aware of deprecated Thread.stop() but can someone please explain what I'm doing wrong here, thanks..
java.lang.UnsupportedOperationException
at java.lang.Thread.stop(Thread.java:1076)
at java.lang.Thread.stop(Thread.java:1063)
at com.dapp.d.SplashScreen$4.run(SplashScreen.java:88)
This is full source code of splashscreen.java
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
public class SplashScreen extends Activity {
private boolean active = true;
private int splashTime = 3000;
private boolean clickFlag = true;
private Thread splashTread = null;
private Button btnHelp;
private Button btnAboutUs;
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
RelativeLayout relativeLayout = (RelativeLayout)findViewById(R.id.splashRelativeLayout);
relativeLayout.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Uri uri = Uri.parse("http://www.exmaple.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
btnAboutUs = (Button)findViewById(R.id.btnAboutus);
btnHelp = (Button)findViewById(R.id.btnHelp);
try{
btnAboutUs.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
clickFlag = false;
splashTread.stop(); <<<<<<<<<<<<<<<<<<< line 49
Intent intent = new Intent();
intent.setClass(getApplicationContext(), AboutUs.class);
startActivity(intent);
SplashScreen.this.finish();
}
});
btnHelp.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
clickFlag = false;
splashTread.stop(); <<<<<<<<<<<<<<<<<<< line 63
Intent intent = new Intent();
intent.setClass(getApplicationContext(), HelpActivity.class);
startActivity(intent);
SplashScreen.this.finish();
}
});
splashTread = new Thread() {
#Override
public void run() {
try{
int waited = 0;
while(active && (waited < splashTime)) {
sleep(100);
waited += 100;
}
} catch(InterruptedException e) {
// do nothing
}finally {
if(clickFlag){
Intent intent=new Intent();
intent.setClass(getApplicationContext(), SearchWord.class);
startActivity(intent);
finish();
stop(); <<<<<<<<<<<<<<< line 88
}else{
finish();
stop();
}
}
}
};
splashTread.start();
}catch (Exception e) {
// TODO: handle exception
}
}
}
I don't think you need to call stop there at all. Your thread doesn't loop so it will execute and end normally. Try just removing the stop();
I had a similar problem and the solution is to wrap the stop method in a try/catch statment and in the catch use Throwable t.
It will work.