2014-02-12 43 views
0

我有一個android應用程序。當使用URL提供RSS時強制關閉。它應該採取數據和顯示。對不起,我英文很差。rss供稿時發現Android文件錯誤

這裏是我的logcat:

enter image description here

這裏是我的活動:

public class Site2 extends FragmentActivity { 
// Connection detector class 
ConnectionDetector cd; 
Boolean isInternetPresent = false; 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    // creating connection detector class instance 
    cd = new ConnectionDetector(getApplicationContext()); 
    // creating connection detector class instance 
      cd = new ConnectionDetector(getApplicationContext()); 



      // get Internet status 
      isInternetPresent = cd.isConnectingToInternet(); 

      // check for Internet status 
      if (isInternetPresent) { 
       // Internet Connection is Present 
       // make HTTP requests 
       showAlertDialog(Site2.this, "Internet Connection", 
         "You have internet connection", true,1); 
      } else { 
       // Internet connection is not present 
       // Ask user to connect to Internet 
       showAlertDialog(Site2.this, "No Internet Connection", 
         "You don't have internet connection.", false,2); 
      } 

    if ((isInternetPresent) &&(savedInstanceState == null)) { 
     addRssFragment(); 
    } 


} 

private void addRssFragment() { 
    FragmentManager manager = getSupportFragmentManager(); 
    FragmentTransaction transaction = manager.beginTransaction(); 
    RssFragment fragment = new RssFragment(); 
    //////////////////////////////////////// 

    Bundle bundle = new Bundle(2); 
    bundle.putInt("url", 1); 
    bundle.putString("url", "http://www.dz-recrutement.blogspot.com/rss.xml"); 
    fragment.setArguments(bundle); 
    ////////////////////////////////////// 
    transaction.add(R.id.fragment_container, fragment); 
    transaction.commit(); 

} 

@Override 
protected void onSaveInstanceState(Bundle outState) { 
    super.onSaveInstanceState(outState); 
    outState.putBoolean("fragment_added", true); 
} 
public void showAlertDialog(Context context, String title, String message, Boolean status,int rol) { 
    AlertDialog alertDialog = new AlertDialog.Builder(context).create(); 

    // Setting Dialog Title 
    alertDialog.setTitle(title); 

    // Setting Dialog Message 
    alertDialog.setMessage(message); 

    // Setting alert dialog icon 
    alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail); 

    switch(rol){ 
    case 1: 
     alertDialog.setButton("OK", new DialogInterface.OnClickListener() { 

      public void onClick(DialogInterface dialog, int which) { 

      } 
     }); 
     break; 
    case 2: 
     alertDialog.setButton("OK", new DialogInterface.OnClickListener() { 

      public void onClick(DialogInterface dialog, int which) { 
       finish(); 
      } 
     }); 
     break; 
} 


    // Showing Alert Message 
    alertDialog.show(); 
} 
} 

我添加的所有權限。請幫幫我。

回答

0

日誌文件說:「FileNotFoundException」,當我進入Url時,該文件不再存在:)。

http://www.dz-recrutement.blogspot.com/rss.xml

那的問題,可以肯定,它的存在。

+0

謝謝。我想烤麪包,如果url不存在。我怎樣才能做到這一點。 –

+0

嗯,黑客將抓住filenotfoundexception。但不要敬酒。用戶不會看到它。做一個內置的加載指標,並顯示一個文本,這是我的第一個想法:)。 –