活动错误甚至以为已在清单中声明

温斯

简而言之,我想说的是,我使用各自引用的2个Intent来改变它们之间的活动,并且我也可以有意图地转到本课程中,但是当我尝试从此类中启动活动时,它会崩溃。

这是我得到错误的类。

    package com.example.wince.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import java.util.ArrayList;

/**
 * Created by Wince on 31.05.2016.
 */
public class RotaGoster extends FragmentActivity implements OnMapReadyCallback {
    private GoogleMap mMap;
    final Intent rotaIntent = new Intent(this, com.example.wince.myapplication.Rota.class);
    final Intent kayitIntent = new Intent(this, com.example.wince.myapplication.RotaKayit.class);

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rota);
        String isim = getIntent().getExtras().getString("DB_name");
        VeriTabani VT = new VeriTabani(this);
        Button Kayit = (Button) findViewById(R.id.button6);
        Button Rota = (Button) findViewById(R.id.button7);
        int i = 0;
        ArrayList<Yer> yerler = new ArrayList<>();
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map2);
        mapFragment.getMapAsync(this);
        yerler.addAll(VT.getAllYer());
        for (i = 0; i < yerler.size(); i++) {
            if (yerler.get(i).equals(isim)) {
                mMap.addMarker(new MarkerOptions().position(new LatLng(VT.getYer(i).getLat(), VT.getYer(i).getLng())).title(i + "'inci nokta"));
            }

        }

        Kayit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(kayitIntent);
                finish();
            }
        });

        Rota.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(rotaIntent);
                finish();
            }
        });


        //dbden verileri çekmek gerek


        // db işlemleri ve gösterim burda yapılıcak.


    }

    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        // Add a marker in Sydney and move the camera
        LatLng sydney = new LatLng(-34, 151);

    }
}

这是android manifest.xml文件

<?xml version="1.0" encoding="utf-8"?>

<!--
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
     Google Maps Android API v2, but you must specify either coarse or fine
     location permissions for the 'MyLocation' functionality. 
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

    <activity
        android:name=".RotaKayit"
        android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

这是错误的日志猫

06-05 15:51:55.032 10275-10275/com.example.wince.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
                                                                             Process: com.example.wince.myapplication, PID: 10275
                                                                             android.content.ActivityNotFoundException: Unable to find explicit activity class {/com.example.wince.myapplication.Rota}; have you declared this activity in your AndroidManifest.xml?
                                                                                 at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1636)
                                                                                 at android.app.Instrumentation.execStartActivity(Instrumentation.java:1430)
                                                                                 at android.app.Activity.startActivityForResult(Activity.java:3532)
                                                                                 at android.app.Activity.startActivityForResult(Activity.java:3493)
                                                                                 at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:842)
                                                                                 at android.app.Activity.startActivity(Activity.java:3735)
                                                                                 at android.app.Activity.startActivity(Activity.java:3703)
                                                                                 at com.example.wince.myapplication.RotaGoster$2.onClick(RotaGoster.java:55)
                                                                                 at android.view.View.performClick(View.java:4633)
                                                                                 at android.view.View$PerformClick.run(View.java:19274)
                                                                                 at android.os.Handler.handleCallback(Handler.java:733)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                 at android.os.Looper.loop(Looper.java:146)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5593)
                                                                                 at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                 at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
                                                                                 at dalvik.system.NativeStart.main(Native Method)
温斯

像这样修改代码; 将意图声明放在oncreate方法中似乎可以解决问题

    package com.example.wince.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import java.util.ArrayList;

/**
 * Created by Wince on 31.05.2016.
 */
public class RotaGoster extends FragmentActivity implements OnMapReadyCallback {
    private GoogleMap mMap;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rota);
        String isim = getIntent().getExtras().getString("DB_name");
        VeriTabani VT = new VeriTabani(this);
        Button Kayit = (Button) findViewById(R.id.button6);
        Button Rota = (Button) findViewById(R.id.button7);
        int i = 0;
        final Intent rotaIntent = new Intent(this, Rota.class);
        final Intent kayitIntent = new Intent(this, RotaKayit.class);
        ArrayList<Yer> yerler = new ArrayList<>();
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map2);
        mapFragment.getMapAsync(this);
        yerler.addAll(VT.getAllYer());
        for (i = 0; i < yerler.size(); i++) {
            if (yerler.get(i).equals(isim)) {
                mMap.addMarker(new MarkerOptions().position(new LatLng(VT.getYer(i).getLat(), VT.getYer(i).getLng())).title(i + "'inci nokta"));
            }

        }

        Kayit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(kayitIntent);
                finish();
            }
        });

        Rota.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(rotaIntent);
                finish();
            }
        });


        //dbden verileri çekmek gerek


        // db işlemleri ve gösterim burda yapılıcak.


    }

    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        // Add a marker in Sydney and move the camera
        LatLng sydney = new LatLng(-34, 151);

    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

未找到Android活动异常...但已在清单中声明

来自分类Dev

而不是在清单错误中声明活动被抛出

来自分类Dev

无法在清单中声明活动

来自分类Dev

未在清单中声明的活动(显然)

来自分类Dev

如何在清单中声明自定义库的活动

来自分类Dev

错误:“视口”已在上层范围中声明

来自分类Dev

android中的清单错误(错误:无法实例化活动ComponentInfo)

来自分类Dev

xy活动不是清单中的具体类错误消息

来自分类Dev

Android清单文件活动错误

来自分类Dev

我是否必须在清单文件中声明所有活动?

来自分类Dev

应用未显示在Google Play商店中,甚至认为它已在开发者控制台中发布并处于活动状态

来自分类Dev

在清单文件中声明意图

来自分类Dev

const限定符已在ctor声明/定义中接受(llvm错误?)

来自分类Dev

错误的未知文件类型,尽管已在头文件中声明并包含了该文件类型

来自分类Dev

该字段已在Serializer上声明,但尚未在Django Rest中包含错误

来自分类Dev

进行活动1时刷新活动2中的清单清单

来自分类Dev

清单文件中的错误

来自分类Dev

清单错误活动不明确

来自分类Dev

尽管已在清单中设置了对SpeechRecognizer的权限,但权限不足

来自分类Dev

尽管已在清单中设置了对SpeechRecognizer的权限,但权限不足

来自分类Dev

无法启动新的活动,表示未在清单上声明

来自分类Dev

即使在清单中声明了ActivityNotFoundException

来自分类Dev

在Android清单中找不到Android活动

来自分类Dev

与在Android中显示清单的活动添加相关

来自分类Dev

在清单中推送错误

来自分类Dev

错误:摘要已在进行中

来自分类Dev

GitHub错误:密钥已在使用中

来自分类常见问题

Docker错误绑定:地址已在使用中

来自分类Dev

套接字错误:地址已在使用中

Related 相关文章

  1. 1

    未找到Android活动异常...但已在清单中声明

  2. 2

    而不是在清单错误中声明活动被抛出

  3. 3

    无法在清单中声明活动

  4. 4

    未在清单中声明的活动(显然)

  5. 5

    如何在清单中声明自定义库的活动

  6. 6

    错误:“视口”已在上层范围中声明

  7. 7

    android中的清单错误(错误:无法实例化活动ComponentInfo)

  8. 8

    xy活动不是清单中的具体类错误消息

  9. 9

    Android清单文件活动错误

  10. 10

    我是否必须在清单文件中声明所有活动?

  11. 11

    应用未显示在Google Play商店中,甚至认为它已在开发者控制台中发布并处于活动状态

  12. 12

    在清单文件中声明意图

  13. 13

    const限定符已在ctor声明/定义中接受(llvm错误?)

  14. 14

    错误的未知文件类型,尽管已在头文件中声明并包含了该文件类型

  15. 15

    该字段已在Serializer上声明,但尚未在Django Rest中包含错误

  16. 16

    进行活动1时刷新活动2中的清单清单

  17. 17

    清单文件中的错误

  18. 18

    清单错误活动不明确

  19. 19

    尽管已在清单中设置了对SpeechRecognizer的权限,但权限不足

  20. 20

    尽管已在清单中设置了对SpeechRecognizer的权限,但权限不足

  21. 21

    无法启动新的活动,表示未在清单上声明

  22. 22

    即使在清单中声明了ActivityNotFoundException

  23. 23

    在Android清单中找不到Android活动

  24. 24

    与在Android中显示清单的活动添加相关

  25. 25

    在清单中推送错误

  26. 26

    错误:摘要已在进行中

  27. 27

    GitHub错误:密钥已在使用中

  28. 28

    Docker错误绑定:地址已在使用中

  29. 29

    套接字错误:地址已在使用中

热门标签

归档