在我的Android应用程序上,有3个片段,每个片段有3个网页浏览量和3个edittexts,我已经注册了一个广播接收器,以便我的网页浏览量填充在其OnReceive()方法上。我希望更新所有3个具有相同内容的片段即收到短信。但我的应用程序每次都崩溃。检查我的代码。
我的主要活动......
public class MainActivity extends ActionBarActivity
implements NavigationDrawerCallbacks {
IntentFilter intentFilter;
private BroadcastReceiver intentReciever = new BroadcastReceiver() {
@Override
public void onReceive(Context context,Intent intent ) {
WebView wv = (WebView) findViewById(R.id.webView);
WebView wv2 = (WebView) findViewById(R.id.webView2);
WebView wv3 = (WebView) findViewById(R.id.webView3);
final String mimeType = "text/html";
final String encoding = "UTF-8";
String html = intent.getExtras().getString("sms");
wv.loadData(html, mimeType, encoding); //no issue if i use only this
wv2.loadData(html, mimeType, encoding); //app crashes here
wv3.loadData(html, mimeType, encoding); //app crashes here
Toast.makeText(getApplicationContext(),"All Fragments Updated",Toast.LENGTH_LONG).show();
}
};
如果我只使用一个webview,显示没问题,但我需要在Onrecieve()上更新所有网页视图...