I am new to android and I am learning android by creating various basic applications to clear my understanding. I have gone through android life cycle so I tried to write below codes.
First one is normal with onCreate() method and Second one is just created with onStart() method but without onCreate() method but still both works properly without any error.
My doubt: How application can start without onCreate() method with Activity as Superclass. Is it not wrong according to life cycle? (But still it is working !)
First One:
import android.content.Intent;
import android.net.Uri;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:+91**********"));
startActivity(intent);
finish();
}
}
Second One:
import android.content.Intent;
import android.net.Uri;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onStart() {
super.onStart();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:+91**********"));
startActivity(intent);
finish();
}
}