마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

스키마 myapp의 파라미터를 안드로이드에서 출력하고 싶은데ㅠ 로그 출력이 안됩니당~

0 추천
안녕하세요^^
스키마 myapp의 파라미터를 안드로이드에서 출력하고 싶은데ㅠ 로그 출력이 안됩니당~
도와주세요ㅠ
 
// test.xml
<html>
<head>
<body>
<a href="myapp://com.example.schematest?var=str&varr=string">Foo</a>
</body>
</head>
</html>
 
// XenoboxCodeLabAppCustomScheme.java
 
package com.example.schematest;
import com.example.schematest.R;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class XenoboxCodeLabAppCustomScheme extends Activity {
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("test.xml");
mWebView.setWebViewClient(new XenoboxWebViewClient());
}

protected class XenoboxWebViewClient extends WebViewClient{

public boolean shoudOverrideUrlLoading(WebView view, String url){
if(url.startsWith("myapp:")){
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
return true;
}
return false;
}
public class XenoboxCustomDataSchemeActivity extends Activity {

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

Intent intent = getIntent();
if(Intent.ACTION_VIEW.equals(intent.getAction())){
Uri uri = intent.getData();
String var = uri.getQueryParameter("var");
String varr = uri.getQueryParameter("varr");

Log.i("xenobx", "var=" + var + "," + "varr" + varr);
}
}
}

public class XenoboxCustomDataSchemeActivity1 extends Activity {
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);

Intent intent = getIntent();
if(Intent.ACTION_VIEW.equals(intent.getAction())){
Uri uri = intent.getData();
String var = uri.getQueryParameter("var");
String varr = uri.getQueryParameter("varr");

Log.i("xenobx", "var=" + var + "," + "varr" + varr);
}
}
}
}
}
 
// AndroidMainfest.xml
 
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.schematest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name=".MainActivity"
android:label="@string/app_name" >

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp"/>
<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>
</activity>
</application>
</manifest>
marimari (520 포인트) 님이 2015년 8월 4일 질문

1개의 답변

0 추천

AndroidMainfest에서 부터 로그를 찍고자 하는 Activity로 설정을 해주셔야 할것같아요.

위 코드대로라며 MainActivity로 설정되어 있어요.

chemkaaa (6,030 포인트) 님이 2015년 8월 4일 답변
...