Search Results

Search found 671 results on 27 pages for 'stub'.

Page 9/27 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • NetworkOnMainThreadException while using AsyncTask

    - by Fansher
    Im making an app that uses the internet to retrive information. I get an NetworkOnMainThreadException as i tried to run it on 3.0 and above and have therefore tried to set it up using AsyncTask, but it still gives the exception and i don't know what is wrong. Oddly enough i read on this thread Android NetworkOnMainThreadException inside of AsyncTask that if you just removes the android:targetSdkVersion="10" statement from the manifest file it will be able to run. This works but i don't find it as the right solution to solve the problem this way. So if anyone can tell me what im doing wrong with the AsyncTask i will really appriciate it. Also if there is anybody that knows why removing the statement in the manifest makes it work, im really interested in that also. My code looks like this: public class MainActivity extends Activity { static ArrayList<Tumblr> tumblrs; ListView listView; TextView footer; int offset = 0; ProgressDialog pDialog; View v; String responseBody = null; HttpResponse r; HttpEntity e; String searchUrl; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnected()) { setContentView(R.layout.main); try { tumblrs = getTumblrs(); listView = (ListView) findViewById(R.id.list); View v = getLayoutInflater().inflate(R.layout.footer_layout, null); footer = (TextView) v.findViewById(R.id.tvFoot); listView.addFooterView(v); listView.setAdapter(new UserItemAdapter(this, R.layout.listitem)); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } new GetChicks().execute(); footer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new loadMoreListView().execute(); } }); } else { setContentView(R.layout.nonet); } } public class UserItemAdapter extends ArrayAdapter<Tumblr> { public UserItemAdapter(Context context, int imageViewResourceId) { super(context, imageViewResourceId, tumblrs); } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.listitem, null); } Tumblr tumblr = tumblrs.get(position); if (tumblr != null) { ImageView image = (ImageView) v.findViewById(R.id.avatar); if (image != null) { image.setImageBitmap(getBitmap(tumblr.image_url)); } } return v; } } public Bitmap getBitmap(String bitmapUrl) { try { URL url = new URL(bitmapUrl); return BitmapFactory.decodeStream(url.openConnection() .getInputStream()); } catch (Exception ex) { return null; } } public ArrayList<Tumblr> getTumblrs() throws ClientProtocolException, IOException, JSONException { searchUrl = "http://api.tumblr.com/v2/blog/"webside"/posts?api_key=API_KEY"; ArrayList<Tumblr> tumblrs = new ArrayList<Tumblr>(); return tumblrs; } private class GetChicks extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... unused) { // TODO Auto-generated method stub runOnUiThread(new Runnable() { public void run() { HttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(searchUrl); HttpResponse r = null; try { r = client.execute(get); int status = r.getStatusLine().getStatusCode(); if (status == 200) { e = r.getEntity(); responseBody = EntityUtils.toString(e); } } catch (ClientProtocolException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } JSONObject jsonObject; try { jsonObject = new JSONObject(responseBody); JSONArray posts = jsonObject.getJSONObject("response") .getJSONArray("posts"); for (int i = 0; i < posts.length(); i++) { JSONArray photos = posts.getJSONObject(i) .getJSONArray("photos"); for (int j = 0; j < photos.length(); j++) { JSONObject photo = photos.getJSONObject(j); String url = photo.getJSONArray("alt_sizes") .getJSONObject(0).getString("url"); Tumblr tumblr = new Tumblr(url); tumblrs.add(tumblr); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); return null; } } public class Tumblr { public String image_url; public Tumblr(String url) { this.image_url = url; } } private class loadMoreListView extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { // Showing progress dialog before sending http request pDialog = new ProgressDialog(MainActivity.this); pDialog.setMessage("More chicks coming up.."); pDialog.setIndeterminate(true); pDialog.setCancelable(false); pDialog.show(); } @Override protected Void doInBackground(Void... unused) { // TODO Auto-generated method stub runOnUiThread(new Runnable() { public void run() { // increment current page offset += 2; // Next page request tumblrs.clear(); String searchUrl = "http://api.tumblr.com/v2/blog/"webside"/posts?api_key=API_KEY&limit=2 + offset; HttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(searchUrl); HttpResponse r = null; try { r = client.execute(get); int status = r.getStatusLine().getStatusCode(); if (status == 200) { HttpEntity e = r.getEntity(); responseBody = EntityUtils.toString(e); } } catch (ClientProtocolException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } JSONObject jsonObject; try { jsonObject = new JSONObject(responseBody); JSONArray posts = jsonObject.getJSONObject("response") .getJSONArray("posts"); for (int i = 0; i < posts.length(); i++) { JSONArray photos = posts.getJSONObject(i) .getJSONArray("photos"); for (int j = 0; j < photos.length(); j++) { JSONObject photo = photos.getJSONObject(j); String url = photo.getJSONArray("alt_sizes") .getJSONObject(0).getString("url"); Tumblr tumblr = new Tumblr(url); tumblrs.add(tumblr); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Setting new scroll position listView.setSelectionFromTop(0, 0); } }); return null; } protected void onPostExecute(Void unused) { pDialog.dismiss(); } } @Override public boolean onCreateOptionsMenu(android.view.Menu menu) { // TODO Auto-generated method stub super.onCreateOptionsMenu(menu); MenuInflater blowUp = getMenuInflater(); blowUp.inflate(R.menu.cool_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Auto-generated method stub switch (item.getItemId()) { case R.id.aboutUs: Intent i = new Intent("com.example.example.ABOUT"); startActivity(i); break; case R.id.refresh: Intent f = new Intent(MainActivity.this, MainActivity.class); startActivity(f); finish(); break; case R.id.exit: finish(); break; } return false; } } Thanks for helping out.

    Read the article

  • jQuery .append() not working in IE, Safari, and Chrome

    - by mkmcdonald
    So I'm using jQuery's AJAX function to read some XML for me and it's worked just fine. But now I'm trying to manipulate the display property of 4 different dynamically generated divs. The size and x/y of the divs are determined by the XML and are parsed through. My problem lies in the face that these divs either aren't being generated or just don't show up in IE, Safari, and Chrome. In Firefox and Opera, they do work. I'm using jQuery's .append() to create the divs and then the .css() functino to manipulate them. Looking in Chrome's developer tools, I am seeing that the css property being changed in the script is being overridden by the property in the stylesheet. Any fixes? $(document).ready(function(){ $.ajax({ type: "GET", url: "generate?test", dataType: "xml", success: function(xml) { $(xml).find('template').each(function(){ var portion = $(this).attr('portion'); var select; var name = $(this).find('$(this):first').text(); var mutability = $(this).attr('mutability'); var x = (parseInt($(this).find('x:first').text())*96)/72; var y = (parseInt($(this).find('y:first').text())*96)/72; switch(portion){ case "stub": select = $('#StubTemplates'); select.append(""+name+""); break; case "body": select = $('#BodyTemplates'); select.append(""+name+""); y = y + 90; break; } switch(mutability){ case "dynamic": var width = (parseInt($(this).find('width:first').text())*96)/72; var height = (parseInt($(this).find('height:first').text())*96)/72; var n = name; switch(portion){ case "stub": $('.ticket').append("") break; case "body": $('.ticket').append(""); break; } var top = $('#'+n).position().top; var left = parseInt($('#'+n).css('margin-left')); $('#'+n).css('top', (y+top)+"px"); $('#'+n).css('margin-left', (x+left)+"px"); $('#'+n).css('width', width+"px"); $('#'+n).css('height', height+"px"); break; case "static": var n = name; switch(portion){ case "stub": $('.ticket').append(""); break; case "body": $('.ticket').append(""); break; } break; } }); var stubActive = false; var bodyActive = false; $('#StubTemplates').find('.ddindent').mouseup(function(){ var tVal = $(this).val(); var tTitle = $(this).attr('title'); if(!stubActive){ $('.stubEditable').css('display', 'none'); $('#'+tVal).css('display', 'block'); stubActive = true; }else{ $('.stubEditable').css('display', 'none'); $('#'+tVal).css('display', 'block'); stubActive = false; } }); $('#StubTemplates').find('#stubTempNone').mouseup(function(){ $('.stubEditable').css('display', 'none'); }); $('#BodyTemplates').find('.ddindent').mouseup(function(){ var tVal = $(this).val(); var tTitle = $(this).attr('title'); if(!bodyActive){ $('.bodyEditable').css('display', 'none'); $('#'+tVal).css('display', 'block'); bodyActive = true; }else{ $('.bodyEditable').css('display', 'none'); $('#'+tVal).css('display', 'block'); bodyActive = false; } }); $('#BodyTemplates').find('#bodyTempNone').mouseup(function(){ $('.bodyEditable').css('display', 'none'); }); } }); });

    Read the article

  • AIDL based two way communication

    - by sshasan
    I have two apps between which I want some data exchanged. As they are running in different processes, so, I am using AIDL to communicate between them. Now, everything is happening really great in one direction (say my apps are A and B) i.e. data is being sent from A to B but, now I need to send some data from B to A. I noticed that we need to include the app with the AIDL in the build path of app where the AIDL method will be called. So in my case A includes B in its build path. For B to be able to send something to A, by that logic, B would need A in its build path. This would create a cycle. I am stuck at this point. And I cannot think of a work around this loop. Any help would be greatly appreciated :) . Thanks! ----EDIT---- So, I following the advice mentioned in one of the comments below, I have the following code In the IPCAIDL project the AIDL file resides, its contents are package ipc.android.aidl; interface Iaidl{ boolean pushBoolean(boolean flag); } This project is being used as a library in both the IPCServer and the IPC Client. The IPCServer Project has the service which defines what happens with the AIDL method. The file is booleanService.java package ipc.android.server; import ipc.android.aidl.Iaidl; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.os.RemoteException; import android.util.Log; public class booleanService extends Service { @Override public IBinder onBind(Intent intent) { return new Iaidl.Stub() { @Override public boolean pushBoolean(boolean arg0) throws RemoteException { Log.i("SERVER(IPC AIDL)", "Truth Value:"+arg0); return arg0; } }; } } The IPCClient file which calls this method is package ipc.android.client2; import ipc.android.aidl.Iaidl; import android.app.Activity; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.view.View; import android.widget.Button; public class IPCClient2Activity extends Activity { Button b1; Iaidl iAIDL; boolean k = false; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); bindService(new Intent("ipc.android.server.booleanService"), conn, Context.BIND_AUTO_CREATE); startService(new Intent("ipc.android.server.booleanService")); b1 = (Button) findViewById(R.id.button1); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(k){ k = false; } else{ k = true; } try { iAIDL.pushBoolean(k); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } private ServiceConnection conn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { // TODO Auto-generated method stub } @Override public void onServiceConnected(ComponentName name, IBinder service) { iAIDL = Iaidl.Stub.asInterface(service); } }; } The manifest file for IPCServer includes the declaration of the service.

    Read the article

  • Sqlite returns error

    - by ruruma
    I'm trying to implement loading data from database and put it into different views. But log cat returns error, that it cannot find "_id" column. Can somebody help me with this? SqlHelper Code public class FiboSqlHelper extends SQLiteOpenHelper { public static final String TABLE_FILMDB = "FiboFilmTop250"; public static final String COLUMN_ID = "_id"; private static final String DATABASE_NAME = "FiboFilmDb250.sqlite"; private static final int DATABASE_VERSION = 1; public static final String COLUMN_TITLE = "Title"; public static final String COLUMN_RATING = "Rating"; public static final String COLUMN_GENRE = "Genre"; public static final String COLUMN_TIME = "Time"; public static final String COLUMN_PREMDATE = "PremDate"; public static final String COLUMN_PLOT = "Plot"; private static final String DATABASE_CREATE = "create table "+TABLE_FILMDB+"("+COLUMN_ID +" integer primary key autoincrement, " +COLUMN_TITLE+" text not null "+COLUMN_RATING+" text not null "+COLUMN_GENRE+" text not null "+COLUMN_TIME+" text not null "+COLUMN_PREMDATE+" text not null "+COLUMN_PLOT+" "+"text not null)"; public FiboSqlHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); // TODO Auto-generated constructor stub } @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL(DATABASE_CREATE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub Log.w(FiboSqlHelper.class.getName(), "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data"); db.execSQL("DROP TABLE IF EXISTS " + TABLE_FILMDB); onCreate(db); } }` SqlAdapterCode: public class FiboSqlAdapter { private SQLiteDatabase database; private FiboSqlHelper dbHelper; private String[] allColumns = {FiboSqlHelper.COLUMN_ID, FiboSqlHelper.COLUMN_TITLE, FiboSqlHelper.COLUMN_GENRE, FiboSqlHelper.COLUMN_PREMDATE, FiboSqlHelper.COLUMN_TIME, FiboSqlHelper.COLUMN_PLOT}; public FiboSqlAdapter (Context context){ dbHelper = new FiboSqlHelper(context); } public void open() throws SQLException { database = dbHelper.getWritableDatabase(); } public void close(){ dbHelper.close(); } public List<FilmDataEntity> getAllFilmData(){ List<FilmDataEntity> fDatas = new ArrayList<FilmDataEntity>(); Cursor cursor = database.query(FiboSqlHelper.TABLE_FILMDB, allColumns, null,null,null,null,null); cursor.moveToFirst(); while(!cursor.isAfterLast()){ FilmDataEntity fData = cursorToData(cursor); fDatas.add(fData); cursor.moveToNext(); } cursor.close(); return fDatas; } private FilmDataEntity cursorToData(Cursor cursor){ FilmDataEntity fData = new FilmDataEntity(); fData.setId(cursor.getLong(1)); fData.setTitle(cursor.getString(2)); fData.setRating(cursor.getString(6)); fData.setGenre(cursor.getString(4)); fData.setPremDate(cursor.getString(5)); fData.setShortcut(cursor.getString(8)); return fData; }} DataEntity: ` public class FilmDataEntity { private long id; private String title; private String rating; private String genre; private String premDate; private String shortcut; public String getShortcut() { return shortcut; } public void setShortcut(String shortcut) { this.shortcut = shortcut; } public String getGenre() { return genre; } public void setGenre(String genre) { this.genre = genre; } public String getPremDate() { return premDate; } public void setPremDate(String premDate) { this.premDate = premDate; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getRating() { return rating; } public void setRating(String rating) { this.rating = rating; } public long getId() { return id; } public void setId(long id) { this.id = id; } } Part from main activity: `List<FilmDataEntity> fE1; sqA = new FiboSqlAdapter(this); sqA.open(); fE1 = sqA.getAllFilmData(); `

    Read the article

  • Getting size of a webpage before parsing it

    - by user2869844
    I am trying to parse a webpage using jsoup and all is working good using this code: class DownloadSearchResultsTask extends AsyncTask<String, Integer, ArrayList> { private String link = "link"; private String title = "title"; private String vote = "vote"; private String age = "age"; private String size = "size"; private String seeders = "seeders"; private String leechers = "leachers"; @Override protected void onPreExecute() { // TODO Auto-generated method stub super.onPreExecute(); } @Override protected ArrayList doInBackground(String... params) { // TODO Auto-generated method stub ArrayList <HashMap<String, String>> searchResult = new ArrayList<HashMap<String, String>>(); HashMap<String, String> map; String link, title, vote, age, size, seeders, leechers; try { HttpURLConnection httpURLConnection=(HttpURLConnection) new URL("http://www.facebook.com").openConnection(); Log.d("VIVZ", httpURLConnection.getContentLength()+""); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Document mDocument; try { long l1=System.nanoTime(); Log.e("VIVZ",l1+""); mDocument = Jsoup .connect(params[0]) .userAgent( "Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6") .referrer("http://www.google.com").get(); long l2=System.nanoTime(); Log.e("VIVZ",(l2-l1)+""); Elements mResults = mDocument.select("div.results dl"); for (Element result : mResults) { map = new HashMap<String, String>(); Elements elements = result.select("dt a"); for (Element linkAndTitle : elements) { link = linkAndTitle.attr("abs:href"); title = linkAndTitle.text(); map.put(this.link, link); map.put(this.title, title); } elements = result.select("dd span.v"); for (Element v : elements) { vote = v.text(); map.put(this.vote, vote); } elements = result.select("dd span.a"); for (Element a : elements) { age = a.text(); map.put(this.age, age); } elements = result.select("dd span.s"); for (Element s : elements) { size = s.text(); map.put(this.size, size); } elements = result.select("dd span.u"); for (Element u : elements) { seeders = u.text(); map.put(this.seeders, seeders); } elements = result.select("dd span.d"); for (Element d : elements) { leechers = d.text(); map.put(this.leechers, leechers); } searchResult.add(map); } Log.e("VIVZ", searchResult.toString()); return searchResult; } catch (IOException e) { // TODO Auto-generated catch block Log.e("VIVZ",e+""); } return null; } @Override protected void onPostExecute(ArrayList result) { // TODO Auto-generated method stub super.onPostExecute(result); } } The problem is i want to get the size of page before parsing it and show a Determinate progress bar please help me ..... thanx in advance

    Read the article

  • Thread safe double buffering

    - by kdavis8
    I am trying to implement a draw map method that will draw the tiled image across the surface of the component. I'm having issue with this code. The double buffering does not seem to be working, because the sprite flickers like crazy; my source code: package myPackage; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Toolkit; import java.awt.image.BufferStrategy; import java.awt.image.BufferedImage; import javax.swing.JFrame; public class GameView extends JFrame implements Runnable { public BufferedImage backbuffer; public Graphics2D g2d; public Image img; Thread gameloop; Scene scene; public GameView() { super("Game View"); setSize(600, 600); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); backbuffer = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); g2d = backbuffer.createGraphics(); Toolkit tk = Toolkit.getDefaultToolkit(); img = tk.getImage(this.getClass().getResource("cage.png")); scene = new Scene(g2d, this); gameloop = new Thread(this); gameloop.start(); } public static void main(String args[]) { new GameView(); } public void paint(Graphics g) { g.drawImage(backbuffer, 0, 0, this); repaint(); } @Override public void run() { // TODO Auto-generated method stub Thread t = Thread.currentThread(); while (t == gameloop) { scene.getScene("dirtmap"); g2d.drawImage(img, 80, 80,this![enter image description here][1]); } } private void drawScene(String string) { // TODO Auto-generated method stub // g2d.setColor(Color.white); // g2d.fillRect(0, 0, getWidth(), getHeight()); scene.getScene(string); } } package myPackage; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Toolkit; public class Scene { Graphics g2d; Component c; boolean loaded = false; public Scene(Graphics2D gr, Component co) { g2d = gr; c = co; } public void getScene(String mapName) { Toolkit tk = Toolkit.getDefaultToolkit(); Image tile = tk.getImage(this.getClass().getResource("dirt.png")); // g2d.setColor(Color.red); for (int y = 0; y <= 18; y++) { for (int x = 0; x <= 18; x += 1) { g2d.drawImage(tile, x * 32, y * 32, c); } } loaded = true; } }

    Read the article

  • Unit Test For NpgsqlCommand With Rhino Mocks

    - by J Pollack
    My unit test keeps getting the following error: "System.InvalidOperationException: The Connection is not open." The Test [TestFixture] public class Test { [Test] public void Test1() { NpgsqlConnection connection = MockRepository.GenerateStub<NpgsqlConnection>(); // Tried to fake the open connection connection.Stub(x => x.State).Return(ConnectionState.Open); connection.Stub(x => x.FullState).Return(ConnectionState.Open); DbQueries queries = new DbQueries(connection); bool procedure = queries.ExecutePreProcedure("201003"); Assert.IsTrue(procedure); } } Code Under Test using System.Data; using Npgsql; public class DbQueries { private readonly NpgsqlConnection _connection; public DbQueries(NpgsqlConnection connection) { _connection = connection; } public bool ExecutePreProcedure(string date) { var command = new NpgsqlCommand("name_of_procedure", _connection); command.CommandType = CommandType.StoredProcedure; NpgsqlParameter parameter = new NpgsqlParameter {DbType = DbType.String, Value = date}; command.Parameters.Add(parameter); command.ExecuteScalar(); return true; } } How would you test the code using Rhino Mocks 3.6? PS. NpgsqlConnection is a connection to a PostgreSQL server.

    Read the article

  • Adding visible "Markers" to represent Geopoints to a MapView using ItemizedOverlay in Android

    - by LordSnoutimus
    Hello, I am building an application which stores GPS locations in a SQLite database and then outputs the data onto a MapView using an Overlay by drawing a red line between the points. I want to be able to show graphical markers (images) for each of these points as well as the red line. My code is as follows: public class MyOverlay extends ItemizedOverlay { // private Projection projection; private Paint linePaint; private Vector points; public MyOverlay(Drawable defaultMarker) { super(defaultMarker); points = new Vector<GeoPoint>(); //set colour, stroke width etc. linePaint = new Paint(); linePaint.setARGB(255, 255, 0, 0); linePaint.setStrokeWidth(3); linePaint.setDither(true); linePaint.setStyle(Style.FILL); linePaint.setAntiAlias(true); linePaint.setStrokeJoin(Paint.Join.ROUND); linePaint.setStrokeCap(Paint.Cap.ROUND); } public void addPoint(GeoPoint point) { populate(); points.addElement(point); } //public void setProjection(Projection projection) { // this.projection = projection; // } public void draw(Canvas canvas, MapView view, boolean shadow) { populate(); int size = points.size(); Point lastPoint = new Point(); if(size == 0) return; view.getProjection().toPixels(points.get(0), lastPoint); Point point = new Point(); for(int i = 1; i<size; i++){ view.getProjection().toPixels(points.get(i), point); canvas.drawLine(lastPoint.x, lastPoint.y, point.x, point.y, linePaint); lastPoint = point; } } @Override protected OverlayItem createItem(int arg0) { // TODO Auto-generated method stub return null; } @Override public int size() { // TODO Auto-generated method stub return 0; } } What would be the easiest way to implement adding markers for each GeoPoint? Thanks

    Read the article

  • Overlay only draws line between first 2 GPS points in Android

    - by LordSnoutimus
    Hi, I am experiencing an unusual error using ItemizedOverlay in Android. I am creating a GPS tracking device that plots a route between waypoints stored in a database. When I provide the first two sets of longitude and latitude points through the emulator in Eclipse, it draws a red line just how I want it, but if I send another GPS point, it animates to the point, but does not draw a line from the last point. public class MyOverlay extends ItemizedOverlay { // private Projection projection; private Paint linePaint; private Vector points; public MyOverlay(Drawable defaultMarker) { super(defaultMarker); points = new Vector<GeoPoint>(); //set colour, stroke width etc. linePaint = new Paint(); linePaint.setARGB(255, 255, 0, 0); linePaint.setStrokeWidth(3); linePaint.setDither(true); linePaint.setStyle(Style.FILL); linePaint.setAntiAlias(true); linePaint.setStrokeJoin(Paint.Join.ROUND); linePaint.setStrokeCap(Paint.Cap.ROUND); } public void addPoint(GeoPoint point) { points.addElement(point); } public void draw(Canvas canvas, MapView view, boolean shadow) { int size = points.size(); Point lastPoint = new Point(); if(size == 0) return; view.getProjection().toPixels(points.get(0), lastPoint); Point point = new Point(); for(int i = 1; i<size; i++){ view.getProjection().toPixels(points.get(i), point); canvas.drawLine(lastPoint.x, lastPoint.y, point.x, point.y, linePaint); lastPoint = point; } } @Override protected OverlayItem createItem(int arg0) { // TODO Auto-generated method stub return null; } @Override public int size() { // TODO Auto-generated method stub return 0; } }

    Read the article

  • Android addTextChangedListener onTextChanged not fired when Backspace is pressed?

    - by tsil
    I use addTextChangeListener to filter a list items. When the user enters a character on the editText, items are filtered based on user input. For example, if the user enters "stackoverflow", all items that contains "stackoverflow" are displayed. It works fine except that once the user press backspace to delete character(s), items are no longer filtered until he deletes all characters. For example, my items are: "stackoverflow 1", "stackoverflow 2", "stackoverflow 3", "stackoverflow 4". If user input is "stackoverflow", all items are displayed. If user input is "stackoverflow 1", only "stackoverflow 1" is displayed. Then user deletes the last 2 characters (1 and the space). User input is now "stackoverflow" but "stackoverflow 1" is still displayed and the other items are not displayed. This is my custom filter: private class ServiceFilter extends Filter { @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults results = new FilterResults(); if (constraint == null || constraint.length() == 0) { // No filter implemented we return all the list results.values = origServiceList; results.count = origServiceList.size(); } else { List<ServiceModel> nServiceList = new ArrayList<ServiceModel>(); for (ServiceModel s : serviceList) { if (s.getName().toLowerCase().contains(constraint.toString().toLowerCase())) { nServiceList.add(s); } } results.values = nServiceList; results.count = nServiceList.size(); } return results; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { if (results.count == 0) { notifyDataSetInvalidated(); } else { serviceList = (List<ServiceModel>) results.values; notifyDataSetChanged(); } } } And how I handle text change event: inputSearch.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { if (cs.length() >= 1) { mAdapter.getFilter().filter(cs); } else { mAdapter = new ServiceAdapter(MyActivity.this, R.layout.ussd_list_item, serviceList); listView.setAdapter(mAdapter); } } });

    Read the article

  • How to configure properly IntelliJ IDEA for deployment of JBoss Seam project?

    - by Piotr Kochanski
    I would like to use IntelliJ IDEA for development of JBoss Seam project. seam-gen is creating the project stub, however the stub is not complete. In particular it is not clear how to deploy such project. First of all I had to define manually web project facelet and add libraries to its deployment definition. The other problem was persistence.xml file. In the Seam generated project it does not exists, since Ant is using one of the persistence-dev.xml, persistence-prod.xml, persistence-test.xml files, changing its name, depending on deployment type (which is ok). Obviously I can create persistence.xml by hand, but it goes againts Seam way of development. Finally I decided to use directly ant, which is not partucularly comfortable. All these tweaks made me think that I am doing something wrong from the IntelliJ IDEA point of view. What is the efficient way of configuring IntelliJ for usage with JBoss Seam (deployment, in particular)? I am using JBoss Seam 2.1.1, Intellij 8.1.4, JBoss 4.3.3

    Read the article

  • AutoCompleteTextView displays 'android.database.sqlite.SQLiteCursor@'... after making selection

    - by user244190
    I am using the following code to set the adapter (SimpleCursorAdapter) for an AutoCompleteTextView mComment = (AutoCompleteTextView) findViewById(R.id.comment); Cursor cComments = myAdapter.getDistinctComments(); scaComments = new SimpleCursorAdapter(this,R.layout.auto_complete_item,cComments,new String[] {DBAdapter.KEY_LOG_COMMENT},new int[]{R.id.text1}); mComment.setAdapter(scaComments); auto_complete_item.xml <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> and thi is the xml for the actual control <AutoCompleteTextView android:id="@+id/comment" android:hint="@string/COMMENT" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="18dp"/> The dropdown appears to work correctly, and shows a list of items. When I make a selection from the list I get a sqlite object ('android.database.sqlite.SQLiteCursor@'... ) in the textview. Anyone know what would cause this, or how to resolve this? thanks Ok I am able to hook into the OnItemClick event, but the TextView.setText() portion of the AutoCompleteTextView widget is updated after this point. The OnItemSelected() event never gets fired, and the onNothingSelected() event gets fired when the dropdown items are first displayed. mComment.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub SimpleCursorAdapter sca = (SimpleCursorAdapter) arg0.getAdapter(); String str = getSpinnerSelectedValue(sca,arg2,"comment"); TextView txt = (TextView) arg1; txt.setText(str); Toast.makeText(ctx, "onItemClick", Toast.LENGTH_SHORT).show(); } }); mComment.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Toast.makeText(ctx, "onItemSelected", Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub Toast.makeText(ctx, "onNothingSelected", Toast.LENGTH_SHORT).show(); } }); Anyone alse have any ideas on how to override the updating of the TextView? thanks patrick

    Read the article

  • Session variables with Cucumber Stories

    - by Matthew Savage
    I am working on some Cucumber stories for a 'sign up' application which has a number of steps. Rather then writing a Huuuuuuuge story to cover all the steps at once, which would be bad, I'd rather work through each action in the controller like a regular user. My problem here is that I am storing the account ID which is created in the first step as a session variable, so when step 2, step 3 etc are visited the existing registration data is loaded. I'm aware of being able to access controller.session[..] within RSpec specifications however when I try to do this in Cucumber stories it fails with the following error (and, I've also read somewhere this is an anti-pattern etc...): Using controller.session[:whatever] or session[:whatever] You have a nil object when you didn't expect it! The error occurred while evaluating nil.session (NoMethodError) Using session(:whatever) wrong number of arguments (1 for 0) (ArgumentError) So, it seems accession the session store isn't really possible. What I'm wondering is if it might be possible to (and I guess which would be best..): Mock out the session store etc Have a method within the controller and stub that out (e.g. get_registration which assigns an instance variable...) I've looked through the RSpec book (well, skimmed) and had a look through WebRat etc, but I haven't really found an answer to my problem... To clarify a bit more, the signup process is more like a state machine - e.g. the user progresses through four steps before the registration is complete - hence 'logging in' isn't really an option (it breaks the model of how the site works)... In my spec for the controller I was able to stub out the call to the method which loads the model based on the session var - but I'm not sure if the 'antipattern' line also applies to stubs as well as mocks? Thanks!

    Read the article

  • J2ME web service client

    - by Wasim
    Hi all , I started to use the Netbeans 6.8 web service client wizard . I created a web service (.Net web service) witch return an object Data. The Data class , contains fileds with many types : int , string , double , Person object and array of Person object. I created the J2ME client code through the wizard and every thing seems ok . I see in the Netbeans project the service and the stub . When I try to call my web service method , say Data GetData() ; Then I have a problem with parsing the returned data from the web service and the client data object . As follows : After finishing to call the web service method , in the stub code : public Data helloWorld() throws java.rmi.RemoteException { Object inputObject[] = new Object[] { }; Operation op = Operation.newInstance( _qname_operation_HelloWorld, _type_HelloWorld, _type_HelloWorldResponse ); _prepOperation( op ); op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "http://tempuri.org/HelloWorld" ); Object resultObj; try { resultObj = op.invoke( inputObject ); } catch( JAXRPCException e ) { Throwable cause = e.getLinkedCause(); if( cause instanceof java.rmi.RemoteException ) { throw (java.rmi.RemoteException) cause; } throw e; } return Data_fromObject((Object[])resultObj); } private static Data Data_fromObject( Object obj[] ) { if(obj == null) return null; Data result = new Data(); result.setIntData(((Integer )obj[0]).intValue()); result.setStringData((String )obj[1]); result.setDoubleData(((Double )obj[2]).doubleValue()); return result; } I debug the code and in Run time resultObj has one element witc is an array of the Data object , so in parsing the values in the Data_fromObject method it expect many cells like we see in the code obj[0] , obj[1] , obj [2] but in realtime it has obj[0][0] , obj[0][1] , obj[0][2] What can be the problem , how can check the code generation issue ? Is it a problem with the web service side. Please help. Thanks in advance...

    Read the article

  • android bindservice

    - by mnish
    hi, I get null pointer exception at line mService.start() when i try to bind to an already started service. I do the same thing from different activity(where the service gets started) everythig goes right. All these activities are part of one application. What do you think I do wrong? public class RouteOnMap extends MapActivity{ private static final int NEW_LOCATION = 1; private static final int GPS_OFF = 2; private MapView mMapView; private ILocService mService; private boolean mServiceStarted; private boolean mBound; private Intent mServiceIntent; private double mLatitude, mLongitude; private ServiceConnection connection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder iservice) { mService = ILocService.Stub.asInterface(iservice); mBound = true; } public void onServiceDisconnected(ComponentName className) { mService = null; mBound = false; } }; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.mapview); mMapView = (MapView) findViewById(R.id.mapview); mMapView.setBuiltInZoomControls(true); mServiceIntent = new Intent(); mLatitude = 0.0; mLongitude = 0.0; mBound = false; } @Override public void onStart(){ super.onStart(); mServiceIntent.setClass(this, LocationService.class); //startService(mServiceIntent); if(!mBound){ mBound = true; this.bindService(mServiceIntent, connection, Context.BIND_AUTO_CREATE); } } @Override public void onResume(){ super.onResume(); try { mService.start(); } catch (RemoteException e) { e.printStackTrace(); } } @Override public void onPause(){ super.onPause(); if(mBound){ this.unbindService(connection); } } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } }

    Read the article

  • Mocking View with RhinoMocks

    - by blu
    We are using MVP (Supervising Controller) for ASP.NET WebForms with 3.5 SP1. What is the preferred way to check the value of a view property that only has the a set operation with RhinoMocks? Here is what we have so far: var service = MockRepository.GenerateStub<IFooService>(); // stub some data for the method used in OnLoad in the presenter var view = MockRepository.GenerateMock<IFooView>(); var presenter = new FooPresenter(view, service); view.Raise(v => v.Load += null, this, EventArgs.Empty); Assert.IsTrue(view.Bars.Count == 10); // there is no get on Bars Should we use Expects or another way, any input would be great. Thanks Update based on Darin Dimitrov's reply. var bars = new List<Bar>() { new Bar() { BarId = 1 } }; var fooService = MockRepository.GenerateStub<IFooService>(); // this is called in OnLoad in the Presenter fooService.Stub(x => x.GetBars()).Return(bars); var view = MockRepository.GenerateMock<IFooView>(); var presenter = new FooPresenter(view, fooService); view.Raise(v => v.Load += null, this, EventArgs.Empty); view.AssertWasCalled(x => x.Bars = bars); // this does not pass This doesn't work. Should I be testing it this way or is there a better way?

    Read the article

  • Overlay only draws between first 2 points in Android

    - by LordSnoutimus
    Hi, I am experiencing an unusual error using ItemizedOverlay in Android. I am creating a GPS tracking device that plots a route between waypoints stored in a database. When I provide the first two sets of longitude and latitude points through the emulator in Eclipse, it draws a red line just how I want it, but if I send another GPS point, it animates to the point, but does not draw a line from the last point. public class MyOverlay extends ItemizedOverlay { // private Projection projection; private Paint linePaint; private Vector points; public MyOverlay(Drawable defaultMarker) { super(defaultMarker); points = new Vector<GeoPoint>(); //set colour, stroke width etc. linePaint = new Paint(); linePaint.setARGB(255, 255, 0, 0); linePaint.setStrokeWidth(3); linePaint.setDither(true); linePaint.setStyle(Style.FILL); linePaint.setAntiAlias(true); linePaint.setStrokeJoin(Paint.Join.ROUND); linePaint.setStrokeCap(Paint.Cap.ROUND); } public void addPoint(GeoPoint point) { points.addElement(point); } public void draw(Canvas canvas, MapView view, boolean shadow) { int size = points.size(); Point lastPoint = new Point(); if(size == 0) return; view.getProjection().toPixels(points.get(0), lastPoint); Point point = new Point(); for(int i = 1; i<size; i++){ view.getProjection().toPixels(points.get(i), point); canvas.drawLine(lastPoint.x, lastPoint.y, point.x, point.y, linePaint); lastPoint = point; } } @Override protected OverlayItem createItem(int arg0) { // TODO Auto-generated method stub return null; } @Override public int size() { // TODO Auto-generated method stub return 0; } }

    Read the article

  • Android: Change the source of ImageView present in ListView

    - by Vivek
    Hi All, I have a ListView specified by list_item.xml Now I need to change the Image in my list inside onListItemClick. How to achieve this? //list_item.xml <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/play" android:id="@+id/img" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:id="@+id/txt" /> </LinearLayout> I have a Custom Adapter to populate my list. Code below is the adapter. public class MyCustomAdapter extends ArrayAdapter<String> { public MyCustomAdapter(Context context, int textViewResourceId, String[] objects) { super(context, textViewResourceId, objects); // TODO Auto-generated constructor stub } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub LayoutInflater inflater=getLayoutInflater(); View row=inflater.inflate(R.layout.list_item, parent, false); TextView label=(TextView)row.findViewById(R.id.txt); label.setText(Sounds[position]); ImageView icon=(ImageView)row.findViewById(R.id.img); icon.setMaxHeight(32); icon.setMaxWidth(32); icon.setPadding(2, 1, 5, 1); icon.setImageResource(R.drawable.play); return row; } } And in onCreate I do the following @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { setListAdapter(new MyCustomAdapter(this, R.layout.list_item, Sounds)); //Sounds --> String array } catch(Exception e) { e.printStackTrace(); } } Now when any row is selected, I need to change the image associated with the selected view. Your help is appreciated. Thanks.

    Read the article

  • changing value of a textview while change in other textview by multiplying

    - by sur007
    Here I am getting parsed data from a URL and now I am trying to change the value of parse data to users only dynamically on an text view and my code is package com.mokshya.jsontutorial; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import com.mokshya.jsontutorialhos.xmltest.R; import android.app.AlertDialog; import android.app.ListActivity; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.EditText; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.Toast; public class Main extends ListActivity { EditText resultTxt; public double C_webuserDouble; public double C_cashDouble; public double C_transferDouble; public double S_webuserDouble; public double S_cashDouble; public double S_transferDouble; TextView cashTxtView; TextView webuserTxtView; TextView transferTxtView; TextView S_cashTxtView; TextView S_webuserTxtView; TextView S_transferTxtView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listplaceholder); cashTxtView = (TextView) findViewById(R.id.cashTxtView); webuserTxtView = (TextView) findViewById(R.id.webuserTxtView); transferTxtView = (TextView) findViewById(R.id.transferTxtView); S_cashTxtView = (TextView) findViewById(R.id.S_cashTxtView); S_webuserTxtView = (TextView) findViewById(R.id.S_webuserTxtView); S_transferTxtView = (TextView) findViewById(R.id.S_transferTxtView); ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); JSONObject json = JSONfunctions .getJSONfromURL("http://ldsclient.com/ftp/strtojson.php"); try { JSONArray netfoxlimited = json.getJSONArray("netfoxlimited"); for (inti = 0; i < netfoxlimited.length(); i++) { HashMap<String, String> map = new HashMap<String, String>(); JSONObject e = netfoxlimited.getJSONObject(i); map.put("date", e.getString("date")); map.put("c_web", e.getString("c_web")); map.put("c_bank", e.getString("c_bank")); map.put("c_cash", e.getString("c_cash")); map.put("s_web", e.getString("s_web")); map.put("s_bank", e.getString("s_bank")); map.put("s_cash", e.getString("s_cash")); mylist.add(map); } } catch (JSONException e) { Log.e("log_tag", "Error parsing data " + e.toString()); } ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.main, new String[] { "date", "c_web", "c_bank", "c_cash", "s_web", "s_bank", "s_cash", }, new int[] { R.id.item_title, R.id.webuserTxtView, R.id.transferTxtView, R.id.cashTxtView, R.id.S_webuserTxtView, R.id.S_transferTxtView, R.id.S_cashTxtView }); setListAdapter(adapter); final ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { @SuppressWarnings("unchecked") HashMap<String, String> o = (HashMap<String, String>) lv .getItemAtPosition(position); Toast.makeText(Main.this, "ID '" + o.get("id") + "' was clicked.", Toast.LENGTH_SHORT).show(); } }); resultTxt = (EditText) findViewById(R.id.editText1); resultTxt.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // TODO Auto-generated method stub resultTxt.setText(""); } }); resultTxt.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub String text; text = resultTxt.getText().toString(); if (resultTxt.getText().length() > 5) { calculateSum(C_webuserDouble, C_cashDouble, C_transferDouble); calculateSunrise(S_webuserDouble, S_cashDouble, S_transferDouble); } else { } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } }); } private void calculateSum(Double webuserDouble, Double cashDouble, Double transferDouble) { String Qty; Qty = resultTxt.getText().toString(); if (Qty.length() > 0) { double QtyValue = Double.parseDouble(Qty); double cashResult; double webuserResult; double transferResult; cashResult = cashDouble * QtyValue; webuserResult = webuserDouble * QtyValue; transferResult = transferDouble * QtyValue; DecimalFormat df = new DecimalFormat("#.##"); String cashResultStr = df.format(cashResult); String webuserResultStr = df.format(webuserResult); String transferResultStr = df.format(transferResult); cashTxtView.setText(String.valueOf(cashResultStr)); webuserTxtView.setText(String.valueOf(webuserResultStr)); transferTxtView.setText(String.valueOf(transferResultStr)); // cashTxtView.setFilters(new InputFilter[] {new // DecimalDigitsInputFilter(2)}); } if (Qty.length() == 0) { cashTxtView.setText(String.valueOf(cashDouble)); webuserTxtView.setText(String.valueOf(webuserDouble)); transferTxtView.setText(String.valueOf(transferDouble)); } } private void calculateSunrise(Double webuserDouble, Double cashDouble, Double transferDouble) { String Qty; Qty = resultTxt.getText().toString(); if (Qty.length() > 0) { double QtyValue = Double.parseDouble(Qty); double cashResult; double webuserResult; double transferResult; cashResult = cashDouble * QtyValue; webuserResult = webuserDouble * QtyValue; transferResult = transferDouble * QtyValue; DecimalFormat df = new DecimalFormat("#.##"); String cashResultStr = df.format(cashResult); String webuserResultStr = df.format(webuserResult); String transferResultStr = df.format(transferResult); S_cashTxtView.setText(String.valueOf(cashResultStr)); S_webuserTxtView.setText(String.valueOf(webuserResultStr)); S_transferTxtView.setText(String.valueOf(transferResultStr)); } if (Qty.length() == 0) { S_cashTxtView.setText(String.valueOf(cashDouble)); S_webuserTxtView.setText(String.valueOf(webuserDouble)); S_transferTxtView.setText(String.valueOf(transferDouble)); } } } and I am getting following error on logcat 08-28 15:04:12.839: E/AndroidRuntime(584): Uncaught handler: thread main exiting due to uncaught exception 08-28 15:04:12.848: E/AndroidRuntime(584): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mokshya.jsontutorialhos.xmltest/com.mokshya.jsontutorial.Main}: java.lang.NullPointerException 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.access$2100(ActivityThread.java:116) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.os.Handler.dispatchMessage(Handler.java:99) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.os.Looper.loop(Looper.java:123) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.main(ActivityThread.java:4203) 08-28 15:04:12.848: E/AndroidRuntime(584): at java.lang.reflect.Method.invokeNative(Native Method) 08-28 15:04:12.848: E/AndroidRuntime(584): at java.lang.reflect.Method.invoke(Method.java:521) 08-28 15:04:12.848: E/AndroidRuntime(584): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 08-28 15:04:12.848: E/AndroidRuntime(584): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 08-28 15:04:12.848: E/AndroidRuntime(584): at dalvik.system.NativeStart.main(Native Method) 08-28 15:04:12.848: E/AndroidRuntime(584): Caused by: java.lang.NullPointerException 08-28 15:04:12.848: E/AndroidRuntime(584): at com.mokshya.jsontutorial.Main.onCreate(Main.java:111) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)

    Read the article

  • IIS 7.5 can't access file from managed code

    - by Bob
    I am working on a project that is click-once deployed from an IIS 7.5 web server. After installing the parent application (i.e. setting up the IIS site) I am able to hit the url for the click-once app's config file from a remote box. HOWEVER, when I attempt to do the same thing from my app (and the stub app below), I get a 401 Unauthorized. What is the difference between hitting the URL from IE, and from a .NET app? The file and directory itself have full control granted to everyone on the webserver at the moment, and I am an admin on the box. We are using Windows Authentication with NTLM only. Thanks, -Bob Here is the stub app that produces the 401 - Unauthorized when on the doc.Load() line. I can hit the same URL successfully from IE and open the file... static void Main(string[] args) { Console.WriteLine("Config Test"); string filename = "http://dev-rs/myClient/myClickOnce/myApp.config.xml"; Console.WriteLine(filename); XmlDocument doc = new XmlDocument(); doc.Load(filename); Console.WriteLine("Loaded"); Console.WriteLine("Inner Text : " + doc.InnerText); }

    Read the article

  • Error while compiling Hello world program for CUDA

    - by footy
    I am using Ubuntu 12.10 and have sucessfully installed CUDA 5.0 and its sample kits too. I have also run sudo apt-get install nvidia-cuda-toolkit Below is my hello world program for CUDA: #include <stdio.h> /* Core input/output operations */ #include <stdlib.h> /* Conversions, random numbers, memory allocation, etc. */ #include <math.h> /* Common mathematical functions */ #include <time.h> /* Converting between various date/time formats */ #include <cuda.h> /* CUDA related stuff */ __global__ void kernel(void) { } /* MAIN PROGRAM BEGINS */ int main(void) { /* Dg = 1; Db = 1; Ns = 0; S = 0 */ kernel<<<1,1>>>(); /* PRINT 'HELLO, WORLD!' TO THE SCREEN */ printf("\n Hello, World!\n\n"); /* INDICATE THE TERMINATION OF THE PROGRAM */ return 0; } /* MAIN PROGRAM ENDS */ The following error occurs when I compile it with nvcc -g hello_world_cuda.cu -o hello_world_cuda.x /tmp/tmpxft_000033f1_00000000-13_hello_world_cuda.o: In function `main': /home/adarshakb/Documents/hello_world_cuda.cu:16: undefined reference to `cudaConfigureCall' /tmp/tmpxft_000033f1_00000000-13_hello_world_cuda.o: In function `__cudaUnregisterBinaryUtil': /usr/include/crt/host_runtime.h:172: undefined reference to `__cudaUnregisterFatBinary' /tmp/tmpxft_000033f1_00000000-13_hello_world_cuda.o: In function `__sti____cudaRegisterAll_51_tmpxft_000033f1_00000000_4_hello_world_cuda_cpp1_ii_b81a68a1': /tmp/tmpxft_000033f1_00000000-1_hello_world_cuda.cudafe1.stub.c:1: undefined reference to `__cudaRegisterFatBinary' /tmp/tmpxft_000033f1_00000000-1_hello_world_cuda.cudafe1.stub.c:1: undefined reference to `__cudaRegisterFunction' /tmp/tmpxft_000033f1_00000000-13_hello_world_cuda.o: In function `cudaError cudaLaunch<char>(char*)': /usr/lib/nvidia-cuda-toolkit/include/cuda_runtime.h:958: undefined reference to `cudaLaunch' collect2: ld returned 1 exit status I am also making sure that I use gcc and g++ version 4.4 ( As 4.7 there is some problem with CUDA)

    Read the article

  • Displaying music list using custom lists instead of array adapters

    - by Rahul Varma
    Hi, I have displayed the music list in a list view. The list is obtained from a website. I have done this using Arraylist. Now, i want to iterate the same program using custom lists and custom adapters instead of array list. The code i have written using array lists is... public class MusicListActivity extends Activity { MediaPlayer mp; File mediaFile; TextView tv; TextView albumtext; TextView artisttext; ArrayList<String> al=new ArrayList<String>(); //ArrayList<String> al=new ArrayList<String>(); ArrayList<String> node=new ArrayList<String>(); ArrayList<String> filepath=new ArrayList<String>(); ArrayList<String> imgal=new ArrayList<String>(); ArrayList<String> album=new ArrayList<String>(); ArrayList<String> artist=new ArrayList<String>(); ListView lv; Object[] webImgListObject; String[] stringArray; XMLRPCClient client; String loginsess; HashMap<?, ?> siteConn = null; //ImageView im; Bitmap img; String s; int d; int j; StreamingMediaPlayer sm; int start=0; Intent i; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.openadiuofile); lv=(ListView)findViewById(R.id.list1); al=getIntent().getStringArrayListExtra("titles"); //node=getIntent().getStringArrayListExtra("nodeid"); filepath=getIntent().getStringArrayListExtra("apath"); imgal=getIntent().getStringArrayListExtra("imgpath"); album=getIntent().getStringArrayListExtra("album"); artist=getIntent().getStringArrayListExtra("artist"); // ArrayAdapter<String> aa=new ArrayAdapter<String>(this,R.layout.row,R.id.text2,al); //lv.setAdapter(aa); try{ lv.setAdapter( new styleadapter(this,R.layout.row, R.id.text2,al)); }catch(Throwable e) { Log.e("openaudio error",""+e.toString()); goBlooey(e); } lv.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){ j=1; try{ d=arg2; String filep=filepath.get(d); String tit=al.get(d); String image=imgal.get(d); String singer=artist.get(d); String movie=album.get(d); sendpath(filep,tit,image,singer,movie); // getpath(n); }catch(Throwable t) { goBlooey(t); } } }); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); if(j==0) {i=new Intent(this,gorinkadashboard.class); startActivity(i);} } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); j=0; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode==KeyEvent.KEYCODE_SEARCH) { Log.i("go","go"); return true; } return(super.onKeyDown(keyCode, event)); } public void sendpath(String n,String nn,String image,String singer,String movie) { Intent ii=new Intent(this,MusicPlayerActivity.class); ii.putExtra("path",n); ii.putExtra("titletxt",nn); //ii.putStringArrayListExtra("playpath",filepath); ii.putExtra("pos",d); ii.putExtra("image",image); ii.putStringArrayListExtra("imagepath",imgal); ii.putStringArrayListExtra("filepath", filepath); ii.putStringArrayListExtra("imgal", imgal); ii.putExtra("movie" ,movie ); ii.putExtra("singer",singer); ii.putStringArrayListExtra("album", album); ii.putStringArrayListExtra("artist",artist); ii.putStringArrayListExtra("tittlearray",al); startActivity(ii); } class styleadapter extends ArrayAdapter<String> { Context context=null; public styleadapter(Context context, int resource, int textViewResourceId, List<String> objects) { super(context, resource, textViewResourceId, objects); this.context=context; } @Override public View getView(int position, View convertView, ViewGroup parent) { final int i=position; LayoutInflater inflater = ((Activity) context).getLayoutInflater(); View v = inflater.inflate(R.layout.row, null); tv=(TextView)v.findViewById(R.id.text2); albumtext=(TextView)v.findViewById(R.id.text3); artisttext=(TextView)v.findViewById(R.id.text1); tv.setText(al.get(i)); albumtext.setText(album.get(i)); artisttext.setText(artist.get(i)); final ImageView im=(ImageView)v.findViewById(R.id.image); s="http://www.gorinka.com/"+imgal.get(i); // displyimg(s,v); // new imageloader(s,im); String imgPath=s; AsyncImageLoaderv asyncImageLoaderv=new AsyncImageLoaderv(); Bitmap cachedImage = asyncImageLoaderv.loadDrawable(imgPath, new AsyncImageLoaderv.ImageCallback() { public void imageLoaded(Bitmap imageDrawable, String imageUrl) { im.setImageBitmap(imageDrawable); } }); im.setImageBitmap(cachedImage); return v; } } public class imageloader implements Runnable{ private String ss; //private View v; //private View v2; private ImageView im; public imageloader(String s, ImageView im) { this.ss=s; //this.v2=v2; this.im=im; Thread thread = new Thread(this); thread.start(); } public void run(){ try { // URL url = new URL(ss); // URLConnection conn = url.openConnection(); // conn.connect(); HttpGet httpRequest = null; httpRequest = new HttpGet(ss); HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = (HttpResponse) httpclient.execute(httpRequest); HttpEntity entity = response.getEntity(); BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); InputStream is = bufHttpEntity.getContent(); // BufferedInputStream bis = new BufferedInputStream(is); Bitmap bm = BitmapFactory.decodeStream(is); Log.d("img","img"); // bis.close(); is.close(); im.setImageBitmap(bm); // im.forceLayout(); // v2.postInvalidate(); // v2.requestLayout(); } catch (Exception t) { Log.e("bitmap url", "Exception in updateStatus()", t); //goBlooey(t); // throw new RuntimeException(t); } } } private void goBlooey(Throwable t) { AlertDialog.Builder builder=new AlertDialog.Builder(this); builder .setTitle("Exception!") .setMessage(t.toString()) .setPositiveButton("OK", null) .show(); } } I have created the SongList.java, SongsAdapter.java and also SongsAdapterView.java. Their code is... public class SongsList { private String titleName; private String movieName; private String singerName; private String imagePath; private String mediaPath; // Constructor for the SongsList class public SongsList(String titleName, String movieName, String singerName,String imagePath,String mediaPath ) { super(); this.titleName = titleName; this.movieName = movieName; this.singerName = singerName; this.imagePath = imagePath; this.mediaPath = mediaPath; } public String gettitleName() { return titleName; } public void settitleName(String titleName) { this.titleName = titleName; } public String getmovieName() { return movieName; } public void setmovieName(String movieName) { this.movieName = movieName; } public String getsingerName() { return singerName; } public void setsingerName(String singerName) { this.singerName = singerName; } public String getimagePath() { return imagePath; } public void setimagePath(String imagePath) { this.imagePath = imagePath; } public String getmediaPath() { return mediaPath; } public void setmediaPath(String mediaPath) { this.mediaPath = mediaPath; } } public class SongsAdapter extends BaseAdapter{ private Context context; private List<SongsList> listSongs; public SongsAdapter(Context context, List<SongsList> listPhonebook){ this.context = context; this.listSongs = listSongs; } public int getCount() { return listSongs.size(); } public Object getItem(int position) { return listSongs.get(position); } public long getItemId(int position) { return position; } public View getView(int position, View view, ViewGroup viewGroup) { SongsList entry = listSongs.get(position); return new SongsAdapterView(context,entry); } } public SongsAdapterView(Context context, SongsList entry) { super(context); this.setOrientation(VERTICAL); this.setTag(entry); // TODO Auto-generated constructor stub View v = inflate(context, R.layout.row, null); TextView tvTitle = (TextView)v.findViewById(R.id.text2); tvTitle.setText(entry.gettitleName()); TextView tvMovie = (TextView)v.findViewById(R.id.text3); tvTitle.setText(entry.getmovieName()); TextView tvSinger = (TextView)v.findViewById(R.id.text1); tvTitle.setText(entry.getsingerName()); addView(v); } } Can anyone please tell me how to display the list using custom lists and custom adapters using the code above???

    Read the article

  • Rhino Mocks and ordered test with unordered calls

    - by Shaddix
    I'm using Rhino.Mocks for testing the system. I'm going to check the order of calling .LoadConfig and .Backup methods. I need .LoadConfig to be the first. Currently the code is like this: var module1 = mocks.Stub<IBackupModule>(); var module2 = mocks.Stub<IBackupModule>(); module1.Expect(x => x.Name).Return("test"); module2.Expect(x => x.Name).Return("test2"); using (mocks.Ordered()) { module1.Expect(x => x.LoadConfig(null)); module2.Expect(x => x.LoadConfig(null)); module1.Expect(x => x.Backup()); module2.Expect(x => x.Backup()); } mocks.ReplayAll(); The problem is, that there's also a call to .Name property, and i'm not interesting when it'll be called: before .LoadConfig or after the .Backup - it just doesn't matter. And when I run this I'm getting Exception: Unordered method call! The expected call is: 'Ordered: { IConfigLoader.LoadConfig(null); }' but was: 'IIdentification.get_Name();' Is there a way to deal with this? Thanks

    Read the article

  • Setting routes in application.ini in Zend Framework

    - by Paul Watson
    I'm a Zend Framework newbie, and I'm trying to work out how to add another route to my application.ini file. I currently have my routes set up as follows: resources.router.routes.artists.route = /artists/:stub resources.router.routes.artists.defaults.controller = artists resources.router.routes.artists.defaults.action = display ...so that /artists/joe-bloggs uses the "display" action of the "artists" controller to dipslay the profile the artist in question - that works fine. What I want to do now is to set up another route so that /artists/joe-bloggs/random-gallery-name goes to the "galleries" action of the "artists" controller. I tried adding an additional block to the application.ini file (beneath the block above) like so: resources.router.routes.artists.route = /artists/:stub/:gallery resources.router.routes.artists.defaults.controller = artists resources.router.routes.artists.defaults.action = galleries ...but when I do that the page at /artists/joe-bloggs no longer works (Zend tries to route it to the "joe-bloggs" controller). How do I set up the routes in application.ini so that I can change the action of the "artists" controller depending on whether "/:gallery" exists? I realise I'm probably making a really stupid mistake, so please point out my stupidity and set me on the right path (no pun intended).

    Read the article

  • Rhino Mocks Partial Mock

    - by dotnet crazy kid
    I am trying to test the logic from some existing classes. It is not possible to re-factor the classes at present as they are very complex and in production. What I want to do is create a mock object and test a method that internally calls another method that is very hard to mock. So I want to just set a behaviour for the secondary method call. But when I setup the behaviour for the method, the code of the method is invoked and fails. Am I missing something or is this just not possible to test without re-factoring the class? I have tried all the different mock types (Strick,Stub,Dynamic,Partial ect.) but they all end up calling the method when I try to set up the behaviour. using System; using MbUnit.Framework; using Rhino.Mocks; namespace MMBusinessObjects.Tests { [TestFixture] public class PartialMockExampleFixture { [Test] public void Simple_Partial_Mock_Test() { const string param = "anything"; //setup mocks MockRepository mocks = new MockRepository(); var mockTestClass = mocks.StrictMock<TestClass>(); //record beahviour *** actualy call into the real method stub *** Expect.Call(mockTestClass.MethodToMock(param)).Return(true); //never get to here mocks.ReplayAll(); //this is what i want to test Assert.IsTrue(mockTestClass.MethodIWantToTest(param)); } public class TestClass { public bool MethodToMock(string param) { //some logic that is very hard to mock throw new NotImplementedException(); } public bool MethodIWantToTest(string param) { //this method calls the if( MethodToMock(param) ) { //some logic i want to test } return true; } } } }

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >