Okay I replaced it with the "application/x-rar-compressed"
and error removed but when I test the code out in browser it still
launches the web browser
Here is the basic code minus other actives but this is the webview
content minus the menu's
public class PS3AndroidManagementSystemProActivity extends Activity {
private class HelloWebViewClient extends WebViewClient {
@Override
public void onLoadResource(WebView view, String url) {
if (url.contains("action=trailer") ||
url.contains("action=video"))
{
Log.w("ps3mang", "trailer clicked:" + url);
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse(url));
startActivity(i);
}
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String
url) {
view.loadUrl(url);
return true;
}
}
private static final int MENU_HOME = 0;
private static final int MENU_DONATE = 1;
private static final int MENU_ABOUT = 2;
private static final int MENU_CHLG = 3;
final Activity activity = this; // added
Boolean isfirsttime = false;
private WebView myweb;
public void downloadfileto(String fileurl, String filename) {
String myString;
try {
FileOutputStream f = new FileOutputStream(filename);
try {
URL url = new URL(fileurl);
URLConnection urlConn = url.openConnection();
InputStream is = urlConn.getInputStream();
BufferedInputStream bis = new
BufferedInputStream(is, 8000);
int current = 0;
while ((current = bis.read()) != -1) {
f.write((byte) current);
}
} catch (Exception e) {
myString = e.getMessage();
}
f.flush();
f.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
myweb = (WebView) findViewById(R.id.WebView);
myweb.setWebViewClient(new HelloWebViewClient());
myweb.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int
progress) {
// Activities and WebViews measure progress
with different
// scales.
// The progress meter will automatically
disappear when we reach
// 100%
activity.setProgress(progress * 100);
}
});
myweb.setDownloadListener(new DownloadListener() {
/* (non-Javadoc)
* @see
android.webkit.DownloadListener#onDownloadStart(java.lang.String,
java.lang.String, java.lang.String, java.lang.String, long)
*/
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("application/x-rar-compressed");
intent.setData(Uri.parse(url));
startActivity(intent);
}
});
Toast.makeText(this, "Please wait",
Toast.LENGTH_LONG).show();
myweb.loadUrl("file:///android_asset/index.html");
myweb.getSettings().setJavaScriptEnabled(true);
myweb.getSettings().setPluginsEnabled(true);
myweb.getSettings().setBuiltInZoomControls(true);
SharedPreferences settings =
getSharedPreferences("MyPrefsFile", 0);
isfirsttime = settings.getBoolean("isfirsttime", false);
if (isfirsttime) {
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("isfirsttime", false);
editor.commit();
downloadfileto(
"http://xxx.xxx.net/cgi-bin/xxx.php",
"/sdcard/wbrvclientid.txt");
Log.w("isfirsttime", "isfirsttime is true");
} else {
Log.w("isfirsttime", "isfirsttime is false");
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en