2011-12-18 2 views
0

오픈 소스 앱을 안드로이드 앱에 통합하려고합니다. 나는 라이브러리 애플 리케이션으로 오픈 소스 애플 리케이션을 만들어 내 안드로이드 매니 페스트 파일에뿐만 아니라 XML을 통합했습니다. 컴파일 오류가 없습니다.android integration library app

제 1 화면은 라이브러리 응용 프로그램의 로그인 화면입니다과를 호출 할 때 그것은에서 자바 랭 클래스 예외 오류를 던지고있다 : loginscreen.java의

m_app = (TodoApplication) getApplication(); 

소스 코드 :

public class LoginScreen extends Activity { 

final static String TAG = LoginScreen.class.getSimpleName(); 

private TodoApplication m_app; 
private Button m_LoginButton; 
private BroadcastReceiver m_broadcastReceiver; 

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

    setContentView(R.layout.login); 

    m_app = (TodoApplication) getApplication(); 

    // supposed to help with the banding on the green background 



    findViewById(R.id.loginbackground).getBackground().setDither(true); 

    IntentFilter intentFilter = new IntentFilter(); 
    intentFilter.addAction("com.todotxt.todotxttouch.ACTION_LOGIN"); 
    m_broadcastReceiver = new BroadcastReceiver() { 
     @Override 
     public void onReceive(Context context, Intent intent) { 
      Intent i = new Intent(context, TodoTxtTouch.class); 
      startActivity(i); 
      finish(); 
     } 
    }; 
    registerReceiver(m_broadcastReceiver, intentFilter); 

    m_LoginButton = (Button) findViewById(R.id.login); 
    m_LoginButton.setOnClickListener(new OnClickListener() { 
     public void onClick(View v) { 
      login(); 
     } 
    }); 

    //final RemoteClient remoteClient = m_app.getRemoteClientManager() 
     // .getRemoteClient(); 
    //if (remoteClient.isAuthenticated()) { 



     switchToTodolist(); 
    //} 
} 

private void switchToTodolist() { 
    Intent intent = new Intent(this, TodoTxtTouch.class); 
    startActivity(intent); 
    finish(); 
} 

@Override 
protected void onDestroy() { 
    super.onDestroy(); 
    unregisterReceiver(m_broadcastReceiver); 
} 


void login() { 
    final RemoteClient client = m_app.getRemoteClientManager() 
      .getRemoteClient(); 

    if (!client.isAvailable()) { 
     Log.d(TAG, "Remote service " + client.getClass().getSimpleName() 
       + " is not available; aborting login"); 
     Util.showToastLong(m_app, R.string.toast_login_notconnected); 
    } else { 
     RemoteLoginTask loginTask = client.getLoginTask(); 
     loginTask.showLoginDialog(this); 
    } 
} 

} 

android manifest.xml의 통합 라이브러리 코드 :

<activity android:name="com.todotxt.todotxttouch.LoginScreen" android:label="@string/app_label" 
     android:theme="@android:style/Theme.NoTitleBar" 
     android:configChanges="keyboardHidden|orientation">  
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
      <category android:name="com.todotxt.todotxttouch.category.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" />    
     </intent-filter> 


    </activity> 

    <activity android:name="com.todotxt.todotxttouch.TodoApplication" /> 

    <activity android:name="com.todotxt.todotxttouch.Filter" android:label="Filter" 
     android:theme="@android:style/Theme.NoTitleBar" /> 
    <activity android:name="com.todotxt.todotxttouch.Preferences" android:label="@string/set_preferences" /> 
    <activity android:name="com.todotxt.todotxttouch.AddTask" android:label="@string/addtask" 
     android:theme="@android:style/Theme.NoTitleBar" 
     android:configChanges="orientation|keyboardHidden" 
     android:windowSoftInputMode="adjustResize"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
     </intent-filter> 
    </activity> 

    <activity-alias android:name="com.todotxt.todotxttouch.AddTaskShortcut" 
     android:targetActivity="com.todotxt.todotxttouch.AddTask" android:label="@string/shortcut_addtask_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.CREATE_SHORTCUT" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity-alias> 
    <activity-alias android:name="com.todotxt.todotxttouch.AddTaskShare" 
     android:targetActivity="com.todotxt.todotxttouch.AddTask" android:label="@string/share_addtask_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.SEND" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:mimeType="text/plain" /> 
     </intent-filter> 
    </activity-alias> 
    <activity android:name="com.todotxt.todotxttouch.HelpActivity" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" /> 
    <activity android:name="com.todotxt.todotxttouch.TodoTxtTouch" android:theme="@android:style/Theme.NoTitleBar" 
     android:configChanges="keyboardHidden|orientation"> 
     <intent-filter> 
      <action android:name="android.intent.action.SEARCH" /> 
     </intent-filter> 
     <meta-data android:name="android.app.searchable" 
      android:resource="@xml/searchable" /> 
    </activity> 

는 사람이 문제를 이해 좀 도와 주 시겠어요. 이

m_app = (TodoApplication) getApplication(); 

로 LoginScreen.java에서 호출되는 ... 나는 Todoapplication.java라는 파일을 데 .... 클래스가 존재, 그래서 그것은 내가 어디에 :

나를 더 설명하게 Java lang 클래스 예외가 발생합니까?

답변

0

Activity.getApplication()<application> 요소의 매니페스트에서 선언 된 응용 프로그램 클래스의 인스턴스를 반환합니다. 나는 당신의 붙여진 명단에서 그것을 보지 못합니다.

에 앱의 애플리케이션 클래스가이면 충분하지 않습니다. 매니페스트에서 명시 적으로 하나 지정해야합니다.

0

어쩌면 스틱의 끝이 잘못되어 사전에 용서를위한 프로그래밍 신을 부탁 할 것입니다.

이클립스에서 개발 중이라고 가정하면 오픈 소스 소스가있는 이클립스에 프로젝트가있는 간단한 경우가 아니며 프로젝트 속성에는 isLibrary 옵션이 표시되어있다. 프로젝트의 속성에서

당신은 라이브러리를 추가 할 수 있으며 Eclipse는 오픈 소스 하나 (그리고 "면 IsLibrary"확인을 가지고있는 사람)을 나열합니다. 단순히 오픈 소스 프로젝트를 선택하여 추가하지 않겠습니까? 그러면 프로젝트가 라이브러리를 추가하고 다시 빌드 할 것입니까?

는 노출 된 모든 public 메소드에 액세스하기 위해 "수입"문을 사용할 수 있습니다, 지금, 라이브러리를 오픈 소스 프로젝트에 액세스 할 수 있습니다.

오픈 소스 라이브러리 프로젝트를 사용하여이 설치 프로세스의 좋은 예는 내가 시각적 난 그냥 쓴 것을 보여주는 튜토리얼 유튜브를 작성하기 위해 실행 바 셜록이다. 다음에서 찾을 수 있습니다. http://www.youtube.com/watch?v=avcp6eD_X2k