Soru & Cevap
RSS Beslemesi

FATAL EXCEPTION: main HATASI

Android stduio platformunda projemi bitirme aşamasında bu hatayı alıyorum sizlere kodları atayım ...

 

 

 

MainActivity.JAVA:

package com.quantumsturkeygmail.fastsocial;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageButton;


public class MainActivity extends AppCompatActivity {

    WebView webV;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        ImageButton imgbtn= (ImageButton) findViewById(R.id.imgbtn);
        imgbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, anassayfa.class);
                MainActivity.this.startActivity(intent);
                MainActivity.this.finish();
            }
        });


        Button facebook= (Button) findViewById(R.id.facebook);
        facebook.setOnClickListener((new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, faceb.class);
                MainActivity.this.startActivity(intent);
                MainActivity.this.finish();

                webV = (WebView) findViewById(R.id.wb);
                webV.getSettings().setJavaScriptEnabled(true);
                webV.setWebViewClient(new WebViewClient());
                webV.setWebChromeClient(new WebChromeClient());
                webV.loadUrl("www.facebook.com");




            }
        }));

        Button twitter= (Button) findViewById(R.id.twitter);
        twitter.setOnClickListener((new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, tw.class);
                MainActivity.this.startActivity(intent);
                MainActivity.this.finish();

                webV = (WebView) findViewById(R.id.wb1);
                webV.getSettings().setJavaScriptEnabled(true);
                webV.setWebViewClient(new WebViewClient());
                webV.setWebChromeClient(new WebChromeClient());
                webV.loadUrl("www.twitter.com");



            }
        }));

        Button youtube= (Button) findViewById(R.id.youtube);
       youtube.setOnClickListener((new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, yt.class);
                MainActivity.this.startActivity(intent);
                MainActivity.this.finish();


                webV = (WebView) findViewById(R.id.wb2);
                webV.getSettings().setJavaScriptEnabled(true);
                webV.setWebViewClient(new WebViewClient());
                webV.setWebChromeClient(new WebChromeClient());
                webV.loadUrl("youtube.com");

            }
        }));

        Button instagram= (Button) findViewById(R.id.instagram);
        instagram.setOnClickListener((new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, in.class);
                MainActivity.this.startActivity(intent);
                MainActivity.this.finish();


                webV = (WebView) findViewById(R.id.wb3);
                webV.getSettings().setJavaScriptEnabled(true);
                webV.setWebViewClient(new WebViewClient());
                webV.setWebChromeClient(new WebChromeClient());
                webV.loadUrl("www.instagram.com");


            }
        }));






        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.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_help) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

AndroidManifest.XML:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.quantumsturkeygmail.fastsocial">

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>



    <activity
        android:name=".anassayfa">
    </activity>

        <activity
            android:name=".faceb">
        </activity>

        <activity
            android:name=".in">
        </activity>

        <activity
            android:name=".tw">
        </activity>

        <activity
            android:name=".yt">
        </activity>




    </application>

</manifest>

 

  • 1 Cevap

    Aldığın crash log'unun tamamını buraya atarsan sorununa daha detaylı bakılabilir, sadece fatal exception: main birşey ifade etmiyor,

    yinede kodlarına bi göz gezdirdim görebildiğim tek hata bulunuğun ana activity'yi kapattıktan sonra (MainActivity.this.finish()) birkaç webview işlemi yapıyor olman (webV = (WebView) findViewById(R.id.wb2); loadUrl vs) acitivity'yi öldürdükten sonra (finish()) o activity'de daha fazla işlem yapamazsın, webview'de url göstermek gibi, eğer finish'()'i çağırdıktan sonra işlem yapmaya kalkarsan envai çeşit hata oluşur

    Adınız
    Bu soruya cevap vermek için üye olmanız veya giriş yapmanız gerekmektedir.