일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- jsr 296
- 선택적조인
- Struts
- Eclipse
- dock
- Android
- GPS
- oracle
- rowspan
- MFC
- node.js
- Spring
- MySQL
- Google Map
- Ajax
- PLSQL
- sencha touch
- jQuery
- tomcat
- appspresso
- 가우스
- ibsheet
- 전자정부프레임워크
- JDOM
- WebLogic
- phonegap
- PHP
- swingx
- JSON
- iBATIS
Archives
- Today
- Total
Where The Streets Have No Name
Appspresso에서 activityListener, webViewClientListener 등록 본문
Developement/Mobile
Appspresso에서 activityListener, webViewClientListener 등록
highheat 2012. 4. 10. 10:53package com.example.ax.echo;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.webkit.WebView;
import com.appspresso.api.AxError;
import com.appspresso.api.AxPlugin;
import com.appspresso.api.AxPluginContext;
import com.appspresso.api.AxRuntimeContext;
import com.appspresso.api.activity.ActivityAdapter;
import com.appspresso.api.activity.ActivityListener;
import com.appspresso.api.view.WebViewClientAdapter;
import com.appspresso.api.view.WebViewClientListener;
public class MyPlugin implements AxPlugin {
private AxRuntimeContext runtimeContext;
private String TAG = "Echo";
private ActivityListener activityListener;
private WebViewClientListener webViewClientListener;
@Override
public void activate(AxRuntimeContext runtimeContext) {
this.runtimeContext = runtimeContext;
activityListener = new ActivityAdapter(){
@Override
public void onActivityPause(Activity activity) {
Log.d(TAG,"onActivityPause");
super.onActivityPause(activity);
}
@Override
public void onActivityResume(Activity activity) {
Log.d(TAG,"onActivityResume");
super.onActivityResume(activity);
}
};
runtimeContext.addActivityListener(activityListener);
webViewClientListener = new WebViewClientAdapter(){
@Override
public void onPageFinished(WebView view, String url) {
Log.d(TAG,"onPageFinished");
super.onPageFinished(view, url);
}
};
runtimeContext.addWebViewClientListener(webViewClientListener);
}
@Override
public void deactivate(AxRuntimeContext runtimeContext) {
this.runtimeContext = null;
runtimeContext.removeActivityListener(activityListener);
runtimeContext.removeWebViewClientListener(webViewClientListener);
}
@Override
public void execute(AxPluginContext context) {
String method = context.getMethod();
if ("echo".equals(method)) {
String message = context.getParamAsString(0, null);
context.sendResult(message);
Intent smsIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:5551212;5551213"));
smsIntent.putExtra("sms_body", "hello world");
runtimeContext.getActivity().startActivity(smsIntent);
}
else {
context.sendError(AxError.NOT_AVAILABLE_ERR);
}
}
}