안드로이드에서 웹뷰로 http://domain.co.kr/test5/index.php 을 불러옵니다.
(index.php는 textarea의 query 값을 json.php으로 전송 후 결과 값을 받습니다.)
전송 후 결과 값을 받은 값(<span class="result" id="outputText"></span> )
json으로 부터 되돌려 받은 outputText 값을
안드로이드 스튜디오에서
복사하기 버튼 / 공유하기버튼(카톡,N드라이브 전송등) 을 만드려면
어떤 예제나 관련된 정보를 얻을 수 있을까요? 안드로이드 자바 인터페이스를 이용하면 된다고는 들었는데,
도움말이나 이와 관련된 예제라도 알려주시면 감사하겠습니다.
초보라서 힘드네요 ㅠㅠ..
* 안드로이드 스튜디오
안들외드 스튜디오에서는 단순히 http://domain.co.kr/test5/index.php 페이지를 웹뷰로 불러옵니다.
* http://domain.co.kr/test5/index.php (웹뷰로 이페이지를 불러옴)
<script>
$(document).ready(function(){
$(function(){
//alert("한글입력기 Jquery");
});
$('#query_btn').click(function() {
//alert($("#query").val() + '\n위 내용을 입력하셨습니다!');
$.ajax({
dataType:'jsonp',
type : "GET",
url : "http://domain.co.kr/test5/json.php?callback=check&q="+$("#query").val(),
//data:{'query':query},
success : function(result) {
// 통신이 성공적으로 이루어졌을 때 이 함수를 타게 된다.
// TODO
console.log(result);
$("#outputText").html( result.message.result.html );
},
/*complete : function(result) {
// 통신이 실패했어도 완료가 되었을 때 이 함수를 타게 된다.
// TODO
console.log(result);
$("#outputText").html( result + "연결에 실패 하였습니다.");
},*/
error : function(xhr, status, error) {
$("#outputText").html("에러가 발생 하였습니다.");
}
});
});
});
</script>
/* query 값을 넣음 */
<textarea id="query" name="query" style="height:130px;"></textarea>
/* json.php으로 부터 받은 결과값을 받음 */ <span class="result" id="outputText"></span>
* http://domain.co.kr/test5/json.php (index.php 페이지에서 json.php 파일 api으로부터 결과값을 받음)
<?php
header("Content-Type:application/json");
$get_q = $_GET['q'];
$get_callback = $_GET['callback'];
$json_file = "http://otherdomain22.com/checker.php?_callback=". $get_callback . "&q=" . $get_q;
#공백제거 100%
$json_file = trim($json_file);
$json_file = str_replace(" ","%20", $json_file);
$json_file = preg_replace("/\s+/","%20", $json_file);
$json_file = file_get_contents($json_file);
echo $json_file;