Google Play에 원격 테스트 장치로 사용할 때 휴대 전화에서 작동하는 앱이 Google Play에 있습니다.하지만 Play 스토어에 업로드 한 다음 휴대 전화에 다운로드하면 모든 패킷을 전송하지 못합니다.Google Play에 추가 할 때 앱이 작동하지 않음
아래 코드를 보면 하루 종일 사용 권한 문제가 내 머리에 긁적 거리는 것을 알고 있습니다.
package com.example.dale.whatismyip;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
* Created by Dale on 22/01/2017.
*/
public class PingActivity extends AppCompatActivity
{
private EditText pingEdit;
private String pingVal;
private TextView finalResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ping);
finalResult = (TextView) findViewById(R.id.result);
pingEdit = (EditText) findViewById(R.id.editText2);
final Button button = (Button) findViewById(R.id.button5);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finalResult.setText("");
pingVal = pingEdit.getText().toString();
if(pingVal.contains(".") && pingVal.length() > 6)
{
PingTest runner = new PingTest();
runner.execute();
}
else
{
finalResult.setText("Invalid Address");
}
}
});
}
private class PingTest extends AsyncTask<String, String, String>
{
private String res;
@Override
protected String doInBackground(String... strings) {
try {
boolean sudo = false;
String cmd = "/system/bin/ping -c 4 -w 4 " + pingVal;
Process p;
if(!sudo)
p= Runtime.getRuntime().exec(cmd);
else{
p= Runtime.getRuntime().exec(new String[]{"su", "-c", cmd});
}
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
String s;
res = "";
while ((s = stdInput.readLine()) != null) {
// CODE TO DO - create an array and populate it
System.out.println(res += s + "\n");
}
p.destroy();
return res;
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
@Override
protected void onPostExecute(String result) {
// execution of result of Long time consuming operation
// CODE TO DO - pass this method both an array of type string and a string
// then do a while loop through it whilst the array is populated and set the value of the textview to the strings
finalResult.setText(result);
}
}
}
안드로이드 스튜디오를 사용하여 usb를 통해 PC를 테스트 해 주셔서 감사합니다. 베타 응용 프로그램으로 플레이 스토어에 업로드하고 몇 가지 사항을 변경하고 작업을 시작했습니다. – Crouch
괜찮습니다. . 당신은 아마 컴퓨터 네트워크를 사용했습니다. 내가 당신의 질문에 대답한다면 그것을 표시하십시오. –
나는 일을 시작했지만 지금은 고장났다. 문제가 무엇인지 모르겠다. 나는 밤새도록 어떤 코드도 건드리지 않았다. – Crouch