CERCA
PER MODELLO
FullScreen Chatbox! :)

Utente del giorno: con ben Thanks ricevuti nelle ultime 24 ore
Utente della settimana: megthebest con ben 7 Thanks ricevuti negli ultimi sette giorni
Utente del mese: megthebest con ben 39 Thanks ricevuti nell'ultimo mese

Visualizzazione dei risultati da 1 a 3 su 3
Discussione:

action bar su tutte le activity :)

Se questa discussione ti è stata utile, ti preghiamo di lasciare un messaggio di feedback in modo che possa essere preziosa in futuro anche per altri utenti come te!
  1. #1
    Senior Droid


    Registrato dal
    May 2012
    Messaggi
    442

    Ringraziamenti
    39
    Ringraziato 17 volte in 16 Posts
    Predefinito

    action bar non funziona nell'activity contenente unity3d

    Ciao,
    ho un problema con l'action bar della mia "applicazione".
    In pratica nell'activity in cui è presente un animazione Unity3d compare in maniera corretta l'action bar, ma i tasti non sono cliccabili, come si può vedere dai due screenshot seguenti :

    Activity main in cui l'action bar funziona correttamente :



    Activity contenente l'animazione di unity3d in cui l'actionbar non è cliccabile :



    Video che forse fa capire un pò meglio il problema :


    ecco il manifest della mia app :

     
    1
    <?xml version="1.0" encoding="utf-8"?>
    2
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    3
        package="com.rabidgremlin.tut.redcube"
    4
        android:installLocation="auto"
    5
        
    6
        android:versionCode="1"
    7
        android:versionName="1.0" >
    8
     <!--  android:theme="@android:style/Theme.NoTitleBar"-->
    9
        <supports-screens
    10
            android:anyDensity="true"
    11
            android:largeScreens="true"
    12
            android:normalScreens="true"
    13
            android:smallScreens="true"
    14
            android:xlargeScreens="true" />
    15
    16
        <application
    17
            android:icon="@drawable/app_icon"
    18
            android:label="@string/app_name"
    19
            android:theme="@android:style/Theme.Holo.Light"  >
    20
             
    21
            <activity
    22
                android:name="com.rabidgremlin.tut.redcube.UnityPl  ayerNativeActivity"
    23
                android:configChanges="mcc|mnc|locale|touchscreen|  keyboard|keyboardHidden|navigation|orientation|scr  eenLayout|uiMode|screenSize|smallestScreenSize|fon  tScale"
    24
                android:label="@string/app_name"
    25
               
    26
                android:screenOrientation="portrait" >
    27
      <!--android:launchMode="singleTask"-->
    28
                <meta-data
    29
                    android:name="unityplayer.UnityActivity"
    30
                    android:value="true" />
    31
                <meta-data
    32
                    android:name="unityplayer.ForwardNativeEventsToDal  vik"
    33
                    android:value="false" />
    34
            </activity>
    35
            <activity
    36
                android:name="com.rabidgremlin.tut.redcube.MainAct  ivity"
    37
                android:label="@string/title_activity_main" >
    38
                <intent-filter>
    39
                    <action android:name="android.intent.action.MAIN" />
    40
    41
                    <category android:name="android.intent.category.LAUNCHER" />
    42
                </intent-filter>
    43
            </activity>
    44
        </application>
    45
    46
        <uses-sdk
    47
            android:minSdkVersion="17"
    48
            android:targetSdkVersion="19" />
    49
    50
        <uses-feature android:glEsVersion="0x00020000" />
    51
    52
    </manifest>   
    53
    54


    e il file java della seconda activity contenente l'animazione di Unity3d

    110
     
    1
    package com.rabidgremlin.tut.redcube;
    2
    3
    import android.app.ActionBar.LayoutParams;
    4
    import android.app.NativeActivity;
    5
    import android.content.res.Configuration;
    6
    import android.graphics.PixelFormat;
    7
    import android.os.Bundle;
    8
    import android.view.KeyEvent;
    9
    import android.view.Menu;
    10
    import android.view.MenuItem;
    11
    import android.view.MotionEvent;
    12
    import android.view.View;
    13
    import android.view.ViewGroup;
    14
    import android.view.WindowManager;
    15
    16
    import com.unity3d.player.UnityPlayer;
    17
    18
    public class UnityPlayerNativeActivity extends NativeActivity
    19
    {
    20
    protected UnityPlayer mUnityPlayer;// don't change the name of this variable; referenced from native code
    21
    22
    // Setup activity layout
    23
    @Override protected void onCreate (Bundle savedInstanceState)
    24
        {
    25
            //requestWindowFeature(Window.FEATURE_NO_TITLE);
    26
            super.onCreate(savedInstanceState);
    27
            getWindow().takeSurface(null);
    28
            //Theme_NoTitleBar_Fullscreen
    29
            setTheme(android.R.style.Theme_Holo_Light);
    30
            getWindow().setFormat(PixelFormat.RGB_565);
    31
    32
            mUnityPlayer = new UnityPlayer(this);
    33
            /*if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
    34
                getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
    35
                                       WindowManager.LayoutParams.FLAG_FULLSCREEN);
    36
            */
    37
            setContentView(mUnityPlayer);
    38
            mUnityPlayer.requestFocus();
    39
        }
    40
    41
    // Quit Unity
    42
    @Override protected void onDestroy ()
    43
    {
    44
    mUnityPlayer.quit();
    45
    super.onDestroy();
    46
    }
    47
    48
    // Pause Unity
    49
    @Override protected void onPause()
    50
    {
    51
    super.onPause();
    52
    mUnityPlayer.pause();
    53
    }
    54
     
    55
    56
    // Resume Unity
    57
    @Override protected void onResume()
    58
    {
    59
    super.onResume();
    60
    mUnityPlayer.resume();
    61
    }
    62
    63
    // This ensures the layout will be correct.
    64
    @Override public void onConfigurationChanged(Configuration newConfig)
    65
    {
    66
    super.onConfigurationChanged(newConfig);
    67
    mUnityPlayer.configurationChanged(newConfig);
    68
    }
    69
    70
    // Notify Unity of the focus change.
    71
    @Override public void onWindowFocusChanged(boolean hasFocus)
    72
    {
    73
    super.onWindowFocusChanged(hasFocus);
    74
    mUnityPlayer.windowFocusChanged(hasFocus);
    75
    }
    76
    // proviamo ad abilitare l'action bar :
    77
    @Override
    78
    public boolean onCreateOptionsMenu(Menu menu) {
    79
    80
    // Inflate the menu; this adds items to the action bar if it is present.
    81
    getMenuInflater().inflate(R.menu.main, menu);
    82
    return true;
    83
    }
    84
    @Override
    85
    public boolean onOptionsItemSelected(MenuItem item) {
    86
    // Handle action bar item clicks here. The action bar will
    87
    // automatically handle clicks on the Home/Up button, so long
    88
    // as you specify a parent activity in AndroidManifest.xml.
    89
    int id = item.getItemId();
    90
    if (id == R.id.action_settings) {
    91
    return true;
    92
    }
    93
    return super.onOptionsItemSelected(item);
    94
    }
    95
    // For some reason the multiple keyevent type is not supported by the ndk.
    96
    // Force event injection by overriding dispatchKeyEvent().
    97
    @Override public boolean dispatchKeyEvent(KeyEvent event)
    98
    {
    99
    if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
    100
    return mUnityPlayer.injectEvent(event);
    101
    return super.dispatchKeyEvent(event);
    102
    }
    103
    104
    // Pass any events not handled by (unfocused) views straight to UnityPlayer
    105
    @Override public boolean onKeyUp(int keyCode, KeyEvent event)     { return mUnityPlayer.injectEvent(event); }
    106
    @Override public boolean onKeyDown(int keyCode, KeyEvent event)   { return mUnityPlayer.injectEvent(event); }
    107
    @Override public boolean onTouchEvent(MotionEvent event)          { return mUnityPlayer.injectEvent(event); }
    108
    /*API12*/ public boolean onGenericMotionEvent(MotionEvent event)  { return mUnityPlayer.injectEvent(event); }
    109
    }
    110


    Cosa potrebbe essere a non far funzionare l'action bar nella seconda activity ?
    Ultima modifica di aeroxr1; 10-06-14 alle 16:06

  2.  
  3. #2
    Androidiani Power User L'avatar di Crotan


    Registrato dal
    Jul 2013
    Località
    Roma
    Messaggi
    1,265
    Smartphone
    Redmi Note 9 Pro

    Ringraziamenti
    401
    Ringraziato 1,445 volte in 626 Posts
    Predefinito

    Cioè? Non è molto chiara come domanda. Posta due screen.

  4. Il seguente Utente ha ringraziato Crotan per il post:

    aeroxr1 (10-06-14)

  5. #3
    Senior Droid


    Registrato dal
    May 2012
    Messaggi
    442

    Ringraziamenti
    39
    Ringraziato 17 volte in 16 Posts
    Predefinito

    Ciao,
    ho modificato il primo post, poichè prima era scritto in un italiano incomprensibile e inoltre ho risolto il problema precedente e se ne è presentato un altro relativo sempre all'action bar.

    Spero possiate aiutarmi
    Ultima modifica di aeroxr1; 10-06-14 alle 09:59

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire risposte
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Torna su
Privacy Policy