Autore Topic: impossibile avviare activity da bottone  (Letto 347 volte)

Offline CRcr

  • Nuovo arrivato
  • *
  • Post: 2
  • Respect: 0
    • Mostra profilo
impossibile avviare activity da bottone
« il: 30 Novembre 2015, 13:55:17 CET »
0
salve,
Sto realizzando un app in Android studio.

In quest'app ho realizzato diverse activity, tra cui Aggiungi e TrovaPosizione.

Se avvio l'emulatore direttamente dall'activity Trovaposizione, essa funziona correttamente.

Se provo tramite il bottone nell'activity "aggiungi" ad avviare l'activity "trovaposizione" l'app si arresta.

Codice: [Seleziona]
11-30 07:52:06.771 19593-19593/? D/dalvikvm: Late-enabling CheckJNI
11-30 07:52:10.691 19593-19593/com.minerva.cristina.datacloud_ W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
11-30 07:52:10.691 19593-19593/com.minerva.cristina.datacloud_ I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
11-30 07:52:10.691 19593-19593/com.minerva.cristina.datacloud_ W/dalvikvm: VFY: unable to resolve interface method 18040: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
11-30 07:52:10.691 19593-19593/com.minerva.cristina.datacloud_ D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
11-30 07:52:10.691 19593-19593/com.minerva.cristina.datacloud_ I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
11-30 07:52:10.691 19593-19593/com.minerva.cristina.datacloud_ W/dalvikvm: VFY: unable to resolve interface method 18044: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
11-30 07:52:10.691 19593-19593/com.minerva.cristina.datacloud_ D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
11-30 07:52:11.419 19593-19593/com.minerva.cristina.datacloud_ D/dalvikvm: GC_FOR_ALLOC freed 92K, 1% free 16627K/16780K, paused 31ms, total 34ms
11-30 07:52:11.443 19593-19593/com.minerva.cristina.datacloud_ I/dalvikvm-heap: Grow heap (frag case) to 16.740MB for 470316-byte allocation
11-30 07:52:11.463 19593-19602/com.minerva.cristina.datacloud_ D/dalvikvm: GC_FOR_ALLOC freed <1K, 1% free 17086K/17240K, paused 18ms, total 18ms
11-30 07:52:11.479 19593-19593/com.minerva.cristina.datacloud_ I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
11-30 07:52:11.479 19593-19593/com.minerva.cristina.datacloud_ W/dalvikvm: VFY: unable to resolve virtual method 492: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
11-30 07:52:11.479 19593-19593/com.minerva.cristina.datacloud_ D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-30 07:52:11.487 19593-19593/com.minerva.cristina.datacloud_ I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
11-30 07:52:11.487 19593-19593/com.minerva.cristina.datacloud_ W/dalvikvm: VFY: unable to resolve virtual method 514: Landroid/content/res/TypedArray;.getType (I)I
11-30 07:52:11.487 19593-19593/com.minerva.cristina.datacloud_ D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-30 07:52:11.519 19593-19593/com.minerva.cristina.datacloud_ I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
11-30 07:52:11.523 19593-19593/com.minerva.cristina.datacloud_ W/dalvikvm: VFY: unable to resolve virtual method 455: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
11-30 07:52:11.531 19593-19593/com.minerva.cristina.datacloud_ D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-30 07:52:11.531 19593-19593/com.minerva.cristina.datacloud_ I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
11-30 07:52:11.539 19593-19593/com.minerva.cristina.datacloud_ W/dalvikvm: VFY: unable to resolve virtual method 457: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
11-30 07:52:11.539 19593-19593/com.minerva.cristina.datacloud_ D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-30 07:52:11.707 19593-19593/com.minerva.cristina.datacloud_ D/libEGL: loaded /system/lib/egl/libEGL_genymotion.so
11-30 07:52:11.711 19593-19593/com.minerva.cristina.datacloud_ D/: HostConnection::get() New Host Connection established 0xb828bc78, tid 19593
11-30 07:52:11.747 19593-19593/com.minerva.cristina.datacloud_ D/libEGL: loaded /system/lib/egl/libGLESv1_CM_genymotion.so
11-30 07:52:11.747 19593-19593/com.minerva.cristina.datacloud_ D/libEGL: loaded /system/lib/egl/libGLESv2_genymotion.so
11-30 07:52:11.891 19593-19593/com.minerva.cristina.datacloud_ W/EGL_genymotion: eglSurfaceAttrib not implemented
11-30 07:52:11.891 19593-19593/com.minerva.cristina.datacloud_ E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache
11-30 07:52:11.907 19593-19593/com.minerva.cristina.datacloud_ E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
11-30 07:52:11.907 19593-19593/com.minerva.cristina.datacloud_ D/OpenGLRenderer: Enabling debug mode 0

Penso sia un problema di collegamento tra activity, ma non so come risolvere.. idee?

Offline Klizard

  • Utente junior
  • **
  • Post: 62
  • Respect: 0
    • Mostra profilo
Re:impossibile avviare activity da bottone
« Risposta #1 il: 30 Novembre 2015, 15:11:32 CET »
0
Posta il codice relativo al pulsante..sicuro di averlo istanziato correttamente? L'Intent lo crei correttamente?

Offline CRcr

  • Nuovo arrivato
  • *
  • Post: 2
  • Respect: 0
    • Mostra profilo
Re:impossibile avviare activity da bottone
« Risposta #2 il: 30 Novembre 2015, 15:17:34 CET »
0
Codice: [Seleziona]
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * Created by Cristina on 28/11/2015.
 */
public class MyBarcodeScannerActivity extends Activity {
    private static final Intent SCAN_INTENT = new Intent("com.google.zxing.client.android.SCAN");


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aggiungi);

        PackageManager packageManager = this.getPackageManager();
        ResolveInfo resolveInfo = packageManager.resolveActivity(SCAN_INTENT, PackageManager.GET_RESOLVED_FILTER);
        if(resolveInfo==null) {
            ((Button)this.findViewById(R.id.scanButton)).setEnabled(false);
            ((TextView)this.findViewById(R.id.scanResult)).setText("Non hai installato nessuna applicazione per effettuare lo scan!!!\nScaricala qui: [url=http://www.appbrain.com/app/com.google.zxing.client.android"]AppBrain[/url]);
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK && requestCode == 0) {
            String scanResult = data.getStringExtra("SCAN_RESULT");
            ((TextView)this.findViewById(R.id.scanResult)).setText(String.format("Risultato dello scan: %1$s", scanResult));
        }
        else {
            ((TextView)this.findViewById(R.id.scanResult)).setText("Operazione annullata!");
        }
    }

    public void onScan(View view) {
        startActivityForResult(SCAN_INTENT, 0);
    }
}