2012-06-06 3 views
0

증강 현실 개념을 기반으로 간단한 앱을 만들었습니다. 이것은 다음 Java 코드입니다.증강 현실 앱 강제 종료

package com.kddi.satch.tutorialactivity;           

import android.app.Activity; 
import android.app.AlertDialog; 
import android.app.Dialog; 
import android.content.DialogInterface; 
import android.content.pm.ApplicationInfo; 
import android.content.pm.PackageManager; 
import android.content.pm.PackageManager.NameNotFoundException; 
import android.os.Bundle; 
import android.os.Handler; 
import android.view.KeyEvent; 
import android.view.View; 
import android.widget.FrameLayout; 

import com.kddi.satch.ARViewer; 
import com.kddi.satch.LoadScenarioStatus; 

public abstract class TutorialActivity_simple extends Activity          
{          
protected abstract String getSampleScenarioName();         
protected abstract String getSampleLogTag();          

protected boolean _isInitializedCorrectly;         
protected ARViewer _kddiComponent;         
protected FrameLayout _frameLayout;         

private static final int DIALOG_EXIT = 0;         

private void resetMembers()         
{         
     _isInitializedCorrectly = false;         
     _frameLayout = null;         
     _kddiComponent = null;        
}         

public void initComponent()         
{         

     _isInitializedCorrectly = false;         

     _kddiComponent = new ARViewer(this);         

     // This FrameLayout must be empty (but initialized) when you pass it to the kddiComponent.initialize() method.        
     _frameLayout = new FrameLayout(this);        
     _kddiComponent.initialize(_frameLayout);         


     _isInitializedCorrectly = true;        
}         

@Override         
public void onCreate(Bundle savedInstanceState) {         
     super.onCreate(savedInstanceState);        

     // Add null to AR Viewer Library compornent's reference.         
     resetMembers();        
}         

@Override         
public void onRestart() {         
     super.onRestart();        
}         

@Override         
public void onStart() {         
    super.onStart();         
    // Create AR Viewer Library compornent.        

    initComponent();         

     postInitComponent();         

    initContentView();        

    if (_isInitializedCorrectly) {        
       // Do authorize and madia is loaded.        
       // You must call loadScenario() method.       
       loadScenario();       
    }        
}         

@Override         
public void onResume(){         
     super.onResume();        

     if (_isInitializedCorrectly) {        
      // GL context is recreated and media is reloaded.       
      _kddiComponent.onResume();       
      reservePlayScenario();       
     }        
}         

@Override         
public void onPause() {         
     // When the activity is paused the GL context is destroyed, so all media is unloaded.        
     if (_isInitializedCorrectly) {        
      cancelReservePlayScenario();        
      if (_kddiComponent.checkLoadScenarioStatus() == LoadScenarioStatus.COMPLETE) {       
       _kddiComponent.pauseScenario();       
      }       
      _kddiComponent.onPause();       
     }        

     super.onPause();         
}         

@Override         
public void onStop() {         
     releaseContentView();        

     // Destroy AR Viewer Library Objects.        
     if (_isInitializedCorrectly)         
     {        
      _kddiComponent.terminate();       
      _kddiComponent = null;       
      _frameLayout = null;        
     }        

     super.onStop();        
}         

@Override         
public void onDestroy() {         
     // Destroy AR Viewer Library Objects.        
     if (_isInitializedCorrectly)         
     {        
      _frameLayout = null;        
      _kddiComponent = null;       
     }        

     super.onDestroy();        

     resetMembers(); // forced clean        
}         

@Override         
public boolean onKeyDown(int keyCode, KeyEvent msg)         
{         
     switch(keyCode){         
       case android.view.KeyEvent.KEYCODE_BACK :       
       showDialog(DIALOG_EXIT);       
       return true;        
    }        
     return false;        
}          

public void postInitComponent()         
{         
     // override this if you need to do some special handling on the component after standard initialization        

     if (_isInitializedCorrectly) {        
      _kddiComponent.activateAutoFocusOnDownEvent(true);       
     }        
}         

public void initContentView()         
{         
     // override this if you need to do some special handling on the component after standard initialization        

     if (_isInitializedCorrectly) {        

      // you'll probably use some other UI object as the content view that itself will embed the component's frame layout -- here you can change all this       

      // by default, the frame layout containing DFusion will be the activity content view        
      setContentView(_frameLayout);       
     }        
}         

public void releaseContentView()          
{         
     // override this if you need to do some special handling on the component after standard initialization        

     if (_isInitializedCorrectly) {        
      // do here the release of the your UI instances (if customized)       
     }        
}         

public void loadScenario()         
{         
     ApplicationInfo appInfo = null;        
     PackageManager packMgmr = getApplicationContext().getPackageManager();        
     try {        
      appInfo = packMgmr.getApplicationInfo(getPackageName(), 0);       
     } catch (NameNotFoundException e) {        
      e.printStackTrace();        
      throw new RuntimeException("Unable to locate assets, aborting...");       
     }        
     String dpdfile = appInfo.sourceDir + getSampleScenarioName();        
     _kddiComponent.loadScenario(dpdfile);        
}         

// Set polling rate for loading the media.         
private final int REPEAT_INTERVAL = 100;          
private Handler handler = new Handler();          
private Runnable runnable = null;         

private void reservePlayScenario()         
{         
     if (runnable == null)        
     {        
     runnable = new Runnable()       
     {       
      @Override      
      public void run()      
      {      
           LoadScenarioStatus status = _kddiComponent.checkLoadScenarioStatus();     
           if (status == LoadScenarioStatus.CANCEL)      
           {     
            // cancel(appli suspend)     
           }     
           else if (status == LoadScenarioStatus.COMPLETE)     
           {     
            // Ready to play scenario    
            _frameLayout.setVisibility(View.VISIBLE);    
            _kddiComponent.playScenario();    
           }     
           else if (     
            status == LoadScenarioStatus.ERROR_NETWORK_UNUSABLE ||    
            // faild to load a media becase of no network connection.    
            status == LoadScenarioStatus.ERROR_NETWORK ||    
            // faild to load a media becase of network error.    
            status == LoadScenarioStatus.ERROR_SOFTWAREKEY ||    
            // faild to load a media becase software key has not be found on server.     
            status == LoadScenarioStatus.ERROR_CONTENT_STOPPED ||    
            // faild to load a media becase content has stopped.     
            status == LoadScenarioStatus.ERROR_SERVER ||     
            // faild to load a media becase of server error.     
            status == LoadScenarioStatus.ERROR_ETC    
            // faild to load a media becase of another error.    
           )     
           {     
            // error     
           }     
           else     
           {     
        handler.postDelayed(this, REPEAT_INTERVAL);    
           }     
      }      
     };       
     handler.postDelayed(runnable, REPEAT_INTERVAL);       
     }        
}         

private void cancelReservePlayScenario()          
{         
     if (handler != null && runnable != null)         
     {        
       handler.removeCallbacks(runnable);       
       runnable = null;        
     }        
}         

protected Dialog onCreateDialog(int id) {         
    Dialog dialog;        
    switch(id) {         
     case DIALOG_EXIT:       
     {       
        AlertDialog.Builder builder = new AlertDialog.Builder(this);       
        builder.setMessage(      
         "Really want to quit the sample?"     
       )      
       .setCancelable(true)       
       .setPositiveButton("Yes", new DialogInterface.OnClickListener() {      
        public void onClick(DialogInterface dialog, int id) {     
           finish();    
        }})     
        .setNegativeButton("No", new DialogInterface.OnClickListener() {       
         public void onClick(DialogInterface dialog, int id) {     
           dialog.cancel();     
         }});      
        dialog = builder.create();      
        break;      
     }       

     default:        
     dialog = null;       
    }        
    return dialog;        
}         
}          
//-- end of file --  

응용 프로그램의 manifest.xml 파일은 내가 에뮬레이터에서 응용 프로그램을 실행 할 때마다 처음으로로드하는 동안, 응용 프로그램의 힘이 닫히고, 지금이

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
android:versionCode="1" 
android:versionName="1.0" package="com.kddi.satch.tutorial"> 
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" 
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:debuggable="false"> 
<!-- configChanges setting --> 
    <activity android:name=".Tutorial" 
     android:label="@string/app_name" 
     android:screenOrientation="landscape" 
      android:configChanges="orientation|keyboard|keyboardHidden" 
      > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

</application> 
<!-- define the resolution --> 
<supports-screens 
    android:anyDensity="false" 
    android:normalScreens="true" 
    android:largeScreens="true" 
    android:smallScreens="true" 
    android:resizeable="true"> 
</supports-screens> 
<!-- permit camera usage if authorized --> 
<uses-permission android:name="android.permission.CAMERA" /> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
<!-- define Autofocus --> 
<uses-feature android:name="android.hardware.camera" /> 
<uses-feature android:name="android.hardware.camera.autofocus" /> 
<uses-sdk android:minSdkVersion="8" /> 

처럼 보인다 다음 오류가 발생합니다.

06-06 22:55:00.157: A /libc(19290): Fatal signal 11 (SIGSEGV) at 0x00000008 (code=1) 
06-06 22:55:00.173: E /ti.dfusionmobile.tiComponent(19290): ON SURFACE CREATED 

내가 잘못하고있는 내용과 위치에 대한 안내는 상당히 유용 할 것입니다. 미리 감사드립니다.

답변

0

실제로 증강 현실 SDK는 전화 GPU를 사용하여 OpenGL 명령을 실행합니다. 이 기능은 에뮬레이터에서 지원되지 않으므로 전화기에서만 응용 프로그램을 실행할 수 있습니다.

최고

+0

동의. 내 휴대 전화에서 그것을 테스트하고 애플 리케이션은 잘 실행되었다. 어쨌든 회신 해 주셔서 감사합니다. – Sanchit