私はアンドロイド開発が初めてです。ネットワーク操作が完了するまでスプラッシュ画面が表示されるように、非同期で実行したいネットワーク データを読み込もうとしています。吊るした状態。
マニフェスト ファイルでも、このアクティビティを LAUNCHER としてマークしました。正しい方法を教えてください。
これがスプラッシュスクリーンのコードです。
public class SplashScreen extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
try{
AsyncTask<Void, Void, HukumNamaDetails> async=new URLReader(splashScreen).execute();
hdetails=async.get();
splashScreen.saveImage(currdate);
}
catch(InterruptedException e) {} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
System.out.println("In finally");
finish();
//start a new activity
Intent i = new Intent();
i.putExtra("hdetails", new HukumNamaDetails(hdetails.getHukumnama_punjabi()
,hdetails.getPunjabi_vyakhya(),hdetails.getEnglish_translation()));
i.setClass(splashScreen, Daily_HukumNama.class);
startActivity(i);
}
}
//Function that will handle the touch
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
synchronized(splashTread){
splashTread.notifyAll();
}
}
return true;
}
}
ありがとうございます