Search Results

Search found 2 results on 1 pages for 'tista'.

Page 1/1 | 1 

  • Starting an Intent to Launch an app to Background in Android

    - by Tista
    Hi all, I'm using Wikitude API 1.1 as an AR viewer in my application. The problem with Wikitude, if I haven't launched the actual Wikitude application since the phone's bootup, I will get a NullPointerException everytime I start my own application. So I figure if I can start my app first and them check if Wikitude is installed and or running. If it's not installed, go to market n download. If it's not running, then we should run it straight to background so that my app doesn't loose its focus. // Workaround for Wikitude this.WIKITUDE_PACKAGE_NAME = "com.wikitude"; PackageManager pacMan = Poligamy.this.getPackageManager(); try { PackageInfo pacInfo = pacMan.getPackageInfo(this.WIKITUDE_PACKAGE_NAME, pacMan.GET_SERVICES); Log.i("CheckWKTD", "Wikitude is Installed"); ActivityManager aMan = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List<RunningAppProcessInfo> runningApps = aMan.getRunningAppProcesses(); int numberOfApps = runningApps.size(); for(int i=0; i<numberOfApps; i++) { if(runningApps.get(i).processName.equals(this.WIKITUDE_PACKAGE_NAME)) { this.WIKITUDE_RUNNING = 1; Log.i("CheckWKTD", "Wikitude is Running"); } } if(this.WIKITUDE_RUNNING == 0) { Log.i("CheckWKTD", "Wikitude is NOT Running"); /*final Intent wIntent = new Intent(Intent.ACTION_MAIN, null); wIntent.addCategory(Intent.CATEGORY_LAUNCHER); final ComponentName cn = new ComponentName("com.wikitude", "com.mobilizy.wikitudepremium.initial.Splash"); wIntent.setComponent(cn); wIntent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); startActivityIfNeeded(wIntent, 0);*/ } } catch (NameNotFoundException e) { // TODO Auto-generated catch block Log.i("CheckWKTD", "Wikitude is NOT Installed"); e.printStackTrace(); //finish(); } The part I block commented is the intent to start Wikitude. But I always failed in restricting Wikitude to background. Any help? Thanks before. Best, Tista

    Read the article

  • Android ListActivity OnListItemClick error with Webviews

    - by Tista
    I've been figuring how to popup a webview all day when a row in my ListActivity is clicked. I can't even show a Toast when it's clicked. Need help I'm still new with Android, a web developer trying to learn. Thanks before. package com.mf.ar; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.app.AlertDialog; import android.app.ListActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.Window; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ArrayAdapter; import android.widget.Toast; public class ListViewer extends ListActivity { private String mJSON; private String[] listRows; private String[] listRowsURI; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.listview); Bundle the = getIntent().getExtras(); this.mJSON = the.getString("JSON"); Log.i("ListViewIntentJSON", this.mJSON); try { JSONObject UrbJSON = new JSONObject(mJSON); JSONObject UrbQuery = UrbJSON.getJSONObject("query"); int rows = UrbQuery.getInt("row"); Log.i("UrbRows", String.format("%d",rows)); JSONArray resultArray = UrbJSON.getJSONArray("result"); this.listRows = new String[rows]; for(int i=0; i<rows; i++) { this.listRows[i] = resultArray.getJSONObject(i). getString("business_name").toString(); } this.listRowsURI = new String[rows]; for(int i=0; i<rows; i++) { this.listRowsURI[i] = resultArray.getJSONObject(i). getString("business_uri_mobile").toString(); } } catch(JSONException e) { e.printStackTrace(); } this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, ListViewer.this.listRows)); } @Override protected void onListItemClick(android.widget.ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); String theURI = ListViewer.this.listRowsURI[position].toString(); /*String theURI = ListViewer.this.listRowsURI[position].toString(); //String theURI = "http://www.mediafusion.web.id"; WebView webview = new WebView(this); //setContentView(webview); //addContentView(webview, null); webview.getSettings().setJavaScriptEnabled(true); getWindow().requestFeature(Window.FEATURE_PROGRESS); final Activity activity = this; webview.setWebChromeClient(new WebChromeClient() { 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 * 1000); } }); webview.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show(); } }); webview.loadUrl(theURI);*/ Toast.makeText(ListViewer.this.getApplicationContext(), theURI, Toast.LENGTH_SHORT); } }

    Read the article

1