I'm trying to make an if statement with the information I got while web scrabing on yahoo finance in Android Studio using jsoup.
I get the value of bitcoin in my textview with the below code, however it's impossible for me to use the value of bitcoin in an "if statement". I tried to use Integer.parseInt(quote.text()) and so on, but my app keeps crasing?
I want to display a text if the value of bitcoin is below or above 70000. Anyone have an idea?
public class MainActivity extends AppCompatActivity {
TextView texx;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
texx=(TextView)findViewById(R.id.textView);
Button button=(Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new doit().execute();
}
});
}
public class doit extends AsyncTask<Void, Void, Void>{
String word;
int a = 70000;
@Override
protected Void doInBackground(Void... voids) {
String url="https://finance.yahoo.com/quote/BTC-USD?p=BTC-USD&.tsrc=fin-srch";
try {
Document doc = Jsoup.connect(url).get();
Element quote = doc.select("span[data-reactid='32']").first();
word = quote.text();
Aucun commentaire:
Enregistrer un commentaire