tags:

views:

58

answers:

1

Please help me In my Project when i m starting new activity it is crashing

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.shortnews); showNewsListView = (ListView)findViewById(R.id.shortnewslistview); ShortNewsListAdapter listAdapter = new ShortNewsListAdapter(this); showNewsListView.setAdapter(listAdapter); showNewsListView.setOnItemClickListener(new OnItemClickListener(){

public void onItemClick(AdapterView arg0, View arg1, int position, long arg3) { newspostion = position; Log.v("status ","tab on position"+position); //showProgressDialog(true); try { Intent myIntent = new Intent(FirstTab.this, NewsWebView.class); FirstTab.this.startActivity(myIntent);

} catch (Exception e) {
 Log.v("error","error in starting new activity");
 e.printStackTrace();
}

} }); getUrlData(baseUrl); } and i m adding this part in manifiest file also ----------------------------this is web view i want to show public void onCreate(Bundle icicle) { super.onCreate(icicle);

    setContentView(R.layout.webview);

    final String mimeType = "text/html";
    final String encoding = "utf-8";

    WebView wv;

    wv = (WebView) findViewById(R.id.wv1);
    wv.loadData("www.gmail.com", mimeType, encoding);

}

------------------------------Log coming 10-29 13:10:15.784: VERBOSE/status(203): tab on position0 10-29 13:10:15.784: INFO/ActivityManager(53): Starting activity: Intent { cmp=org.nuvus/.NewsWebView } 10-29 13:10:15.814: DEBUG/PhoneWindow(203): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@4377c300 has no id. 10-29 13:10:16.764: INFO/ActivityManager(53): Displayed activity org.nuvus/.NewsWebView: 925 ms (total 925 ms) 10-29 13:10:16.794: INFO/AndroidRuntime(203): AndroidRuntime onExit calling exit(0) 10-29 13:10:16.904: INFO/ActivityManager(53): Process org.nuvus (pid 203) has died. 10-29 13:10:16.924: INFO/WindowManager(53): WIN DEATH: Window{438425d8 org.nuvus/org.nuvus.Main paused=true} 10-29 13:10:16.924: INFO/WindowManager(53): WIN DEATH: Window{438e15c8 org.nuvus/org.nuvus.NewsWebView paused=false} 10-29 13:10:17.064: WARN/UsageStats(53): Unexpected resume of com.android.launcher while already resumed in org.nuvus 10-29 13:10:17.144: WARN/InputManagerService(53): Got RemoteException sending setActive(false) notification to pid 203 uid 10027 10-29 13:13:45.264: DEBUG/dalvikvm(102): GC freed 7488 objects / 406792 bytes in 313ms

10-29 13:10:16.794: INFO/AndroidRuntime(203): AndroidRuntime onExit calling exit(0)

A: 

Ok neeraj: Use Asynchronous Task as shown below:

    tabHost.getTabWidget().getChildAt(4).setOnTouchListener(
            new OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    // TODO Auto-generated method stub
                        new San_FirstTask().execute();//calling Asynronchonous Task

                }
            });

// write an asynchronous task

private class San_FirstTask extends AsyncTask<Void, Void, Void> {
        private final ProgressDialog dialog = new ProgressDialog(BS_Main.this);
        String san_url;
        // can use UI thread here
        protected void onPreExecute() {
            this.dialog.setMessage("Loading...");
            this.dialog.setCancelable(false);
            this.dialog.show();

        }

        @Override
        protected Void doInBackground(Void... params) {
            try {


        }

        protected void onPostExecute(Void result) {
            Intent myIntent = new Intent(FirstTab.this, NewsWebView.class);
   startActivity(myIntent);


//          }
            if (this.dialog.isShowing()) {
                this.dialog.dismiss();
            }
        }
Tilsan The Fighter
@neeraj:did u try this,
Tilsan The Fighter
yes this works Thanks
neeraj
@Neeraj: Ok then Accept this answer and vote me
Tilsan The Fighter
Ya sure , can u explain what was the prob in my code so i will not do in future
neeraj
@Neeraj: We have to use Asynchronous Task to start our new Activity on Tab Click event.
Tilsan The Fighter