Hallo,
ich programmiere gerade, wenn ich auf eine Benachrichtigung klicke, dann soll sich eine Webseite im webview öffnen. Wenn ich auf die Benachrichtigung klicke, dann stürz die App ab und folgender Fehler kommt.
[MainActivity.java
Java: MainActivity.java
package net.villi_designs.nexusprimeapp;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.firebase.messaging.FirebaseMessaging;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
public static View view2;
public static View view1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent emailintent = new Intent(Intent.ACTION_SEND);
String[] recipients = new String[]{"[email protected]", "",};
emailintent.putExtra(Intent.EXTRA_EMAIL, recipients);
emailintent.putExtra(Intent.EXTRA_SUBJECT, "Verbesserungen an App Nexus Prime");
emailintent.setType("text/plain");
startActivity(Intent.createChooser(emailintent, "Send mail..."));
}
});
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
WebView web = (WebView) findViewById(R.id.webview1);
WebView webb = (WebView) findViewById(R.id.webview2);
web.setWebViewClient(new WebViewClient());
web.loadUrl("http://nexusprime.de/");
web.getSettings().setJavaScriptEnabled(true);
FirebaseMessaging.getInstance().subscribeToTopic(FCM_Instens_ID_services.infotoppikname);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
//Snackbar.make(findViewById(R.id.drawer_layout), "Topic aboniert", Snackbar.LENGTH_SHORT).show();
}
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
WebView web = (WebView) findViewById(R.id.webview1);
WebView webb = (WebView) findViewById(R.id.webview2);
//webview1
web.setWebViewClient(new WebViewClient());
web.getSettings().setJavaScriptEnabled(true);
view1 = (WebView) findViewById(R.id.webview1);
//webview1
webb.setWebViewClient(new WebViewClient());
webb.getSettings().setJavaScriptEnabled(true);
view2 = (WebView) findViewById(R.id.webview2);
int id = item.getItemId();
if (id == R.id.start) {
web.loadUrl("http://www.nexusprime.de/");
view2.setVisibility(View.INVISIBLE);
view1.setVisibility(View.VISIBLE);
} else if (id == R.id.apply) {
web.loadUrl("http://www.nexusprime.de/apply/");
view2.setVisibility(View.INVISIBLE);
view1.setVisibility(View.VISIBLE);
} else if (id == R.id.forum) {
web.loadUrl("http://www.nexusprime.de/forum/");
view2.setVisibility(View.INVISIBLE);
view1.setVisibility(View.VISIBLE);
} else if (id == R.id.coki) {
web.loadUrl("http://www.nexusprime.de/?page_id=53");
view2.setVisibility(View.INVISIBLE);
view1.setVisibility(View.VISIBLE);
} else if (id == R.id.shop) {
webb.loadUrl("http://shop.nexusprime.de/");
view2.setVisibility(View.VISIBLE);
view1.setVisibility(View.INVISIBLE);
} else if (id == R.id.login) {
web.loadUrl("http://www.nexusprime.de/login/");
view2.setVisibility(View.INVISIBLE);
view1.setVisibility(View.VISIBLE);
} else if (id == R.id.nav_share) {
Intent shahre = new Intent(Intent.ACTION_SEND);
shahre.putExtra(Intent.EXTRA_TEXT, "Installiere dir jetzt die Nexus Prime App: http://nexusprime.de/?page_id=157");
shahre.setType("text/plain");
startActivity(Intent.createChooser(shahre, "Teilen Via..."));
} else if (id == R.id.nav_send) {
Intent emailintent = new Intent(Intent.ACTION_SEND);
String[] recipients = new String[]{"[email protected]", "",};
emailintent.putExtra(Intent.EXTRA_EMAIL, recipients);
emailintent.putExtra(Intent.EXTRA_SUBJECT, "Verbesserungen an App Nexus Prime");
emailintent.setType("text/plain");
startActivity(Intent.createChooser(emailintent, "Send mail..."));
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
public static boolean showweb(){
final WebView wv1 = (WebView) view1.findViewById(R.id.webview1);
final WebView wv2 = (WebView) view2.findViewById(R.id.webview2);
wv1.loadUrl("http://www.nexusprime.de/update/");
wv1.setWebViewClient(new WebViewClient());
wv1.getSettings().setJavaScriptEnabled(true);
wv1.setVisibility(View.VISIBLE);
wv2.setVisibility(View.INVISIBLE);
return true;
}
}
Alles anzeigen
Ich hoffe mir kann jemand helfen.