Notes
![]() ![]() Notes - notes.io |
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity
{
TextView tv;
int sayac = 0;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView) findViewById(R.id.tv);
new AsyncTask<String, Integer, String>()
{
ProgressDialog pd;
// Ön Hazırlık Method
protected void onPreExecute()
{
Log.e("x","Pre Execute Calisti");
pd = new ProgressDialog(MainActivity.this);
pd.setMessage("Lütfen Bekleyin");
pd.show();
}
// Uzun Sürecek İşin Yapılacağı Method
protected String doInBackground(String... strings)
{
Log.e("x","doInBackground Calisti");
for (int i = 50000; i <=250000; i++)
if (isPrime(i))
{
sayac++;
// doInBackground'ta Calisirken, Periodik Olarak UI Update Edilmek İsteniyorsa
// publishProgress Methoduna İstediğiniz Değerler Gönderilir
// publishProgress Methoduna Verilen Parametreler,
// UI Thread Icinde Calisan,
// onProgressUpdate Methoduna Geri Gonderilir,
// onProgressUpdate Icinde, Istenilen Islem Yapilir
publishProgress(sayac);
}
return null;
}
// DoInBackground Icinden, publishProgress'le Gonderilen Degerler
// bu Methodda UI'da Değişiklik Yapmak Icin Kullanılır
protected void onProgressUpdate(Integer... values) {
tv.setText(""+values[0]);
}
// Son Evre
protected void onPostExecute(String s)
{
pd.dismiss();
Log.e("x","Post Execute Calisti");
tv.setText("Count : "+sayac);
}
}.execute();
}
public boolean isPrime(int n)
{
if (n <= 1) return false;
for (int i = 2; i<n; i++)
if (n % i == 0)
return false;
return true;
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team