2011-05-12 2 views
0

그래서이확인 앱의 설치

public class Notes extends Activity { 

    WebView mWebView; 

    /** Called when the activity is first created. */ 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.timsnotes); 

     mWebView = (WebView) findViewById(R.id.webview3); 
     mWebView.getSettings().setJavaScriptEnabled(true); 
     mWebView.loadUrl("http://www.somedomain.com/notes.php?phoneid=" + "sID" + ""); 
     mWebView.setWebViewClient(new HelloWebViewClient()); 
    } 

하지만 모든 그림과 같이 나는 웹보기가 URL로 이동 한 다른 자바 클래스에 다음 코드

public class Installation { 
    private static String sID = null; 
    private static final String INSTALLATION = "INSTALLATION"; 

    public synchronized static String id(Context context) { 
     if (sID == null) { 
      File installation = new File(context.getFilesDir(), INSTALLATION); 
      try { 
       if (!installation.exists()) 
        writeInstallationFile(installation); 
       sID = readInstallationFile(installation); 
      } catch (Exception e) { 
       throw new RuntimeException(e); 
      } 
     } 
     return sID; 
    } 

    private static String readInstallationFile(File installation) throws IOException { 
     RandomAccessFile f = new RandomAccessFile(installation, "r"); 
     byte[] bytes = new byte[(int) f.length()]; 
     f.readFully(bytes); 
     f.close(); 
     return new String(bytes); 
    } 

    private static void writeInstallationFile(File installation) throws IOException { 
     FileOutputStream out = new FileOutputStream(installation); 
     String id = UUID.randomUUID().toString(); 
     out.write(id.getBytes()); 
     out.close(); 
    } 
} 

를 사용하여 응용 프로그램의 설치 확인에 좋은 블로그 그것은 sID 텍스트입니다. sID에 액세스하기 위해 누락 된 사용 권한이 있습니까?

답변

0

"sID"대신 Installation.id (this)를 사용하십시오. 그러면 id가 문자열로 구문 분석됩니다. 현재 "sID"를 전달 중입니다.

관련 문제