[android-developers] Digest for android-developers@googlegroups.com - 7 updates in 7 topics

Jeffrey Nielsen <slushbilly@gmail.com>: Jun 04 08:26PM -0700

My API is 23. I am having issues where my device does not send the
connection request. I have tried on the emulator, a phone running 6.0, and
a tablet with 5.1.
Can someone please give me some assistance? Been banging my head against
the wall for hours now.
import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.os.Bundle;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class MainActivity extends Activity {
* Called when the activity is first created.
public void onCreate(Bundle savedInstanceState) {
final Button ConnectButton = (Button) findViewById(R.id.ConnectButton);
final TextView IpAddressEntry = (TextView) findViewById(R.id.IpAddressEntry);
final TextView PortEntry = (TextView) findViewById(R.id.PortEntry);
String IpAddress = IpAddressEntry.getText().toString();
String Port = PortEntry.getText().toString();
ConnectButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
HttpURLConnection connection = null;
String IpAddress = IpAddressEntry.getText().toString();
String Port = PortEntry.getText().toString();
try {
String urlConnect = "http://" + IpAddress + ":" + Port + "/connect";
URL url = new URL(urlConnect);
connection = (HttpURLConnection) url.openConnection();
Log.i(urlConnect, "myIP");
InputStream is = connection.getInputStream();
BufferedReader reader =new BufferedReader(new InputStreamReader(is, "UTF-8"));
String webPage = "",data="";
while ((data = reader.readLine()) != null){
webPage += data + "\n";
} catch (Exception e) {
} finally {
if (connection != null) {
Amit Shekhar <amit.shekhar.iitbhu@gmail.com>: Jun 04 07:21PM -0700

abeer.shlby@gmail.com: Jun 04 04:35PM -0700

I have app inside it only one activity (main activity) and layout XML of
main activity have only
list view .this app get restaurants near from my location and display it in
list view
What i need to do is add button to the main activity layout when i press on
button get to me list of restaurant item by item
from json file and display it in list view but not display all restaurants
in one click but show item by item
every click get restaurant
suppose i have 3 restaurant in json file
when i click on button for first click get me first restaurant
when i click on button for second click get me second restaurant
when i click on button for third click get me third restaurant
How to customize this code to accept get item by item restaurant from json
My code include class and activity and code is working success
my class is FoursquareVenue
package com.foodsmap_project_app.foodsmap_project_app;
public class FoursquareVenue
private String name;
private String city;
private String category;
public FoursquareVenue() {
this.name = "";
this.city = "";
public String getCity() {
if (city.length() > 0) {
return city;
return city;
public void setCity(String city) {
if (city != null) {
this.city = city.replaceAll("\\(", "").replaceAll("\\)", "");
public void setName(String name) {
this.name = name;
public String getName() {
return name;
public String getCategory() {
return category;
public void setCategory(String category) {
this.category = category;
public class MainActivity extends ListActivity {
ArrayList<FoursquareVenue> venuesList;
final String CLIENT_ID =
final String CLIENT_SECRET =
final String latitude = "30.435665153239377";
final String longtitude = "31.3280148";
ArrayAdapter <String> myAdapter;
protected void onCreate(Bundle savedInstanceState)
new fourquare().execute();
private class fourquare extends AsyncTask<View, Void, String> {
String temp;
protected String doInBackground(View... urls) {

temp =
makeCall("https://api.foursquare.com/v2/venues/search?client_id=" +
CLIENT_ID + "&client_secret=" + CLIENT_SECRET +
"&v=20130815&ll=30.435665153239377,31.144435908398464" +

return "";
protected void onPreExecute() {
protected void onPostExecute(String result) {
if (temp == null) {
} else {
venuesList = (ArrayList<FoursquareVenue>)
List<String> listTitle = new ArrayList<String>();
for (int i = 0; i < venuesList.size(); i++) {
listTitle.add(i, venuesList.get(i).getName() + ", " +
venuesList.get(i).getCategory() + "" + venuesList.get(i).getCity());
myAdapter = new ArrayAdapter<String>(MainActivity.this,
R.layout.row_layout, R.id.listText, listTitle);
public static String makeCall(String url) {
StringBuffer buffer_string = new StringBuffer(url);
String replyString = "";
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(buffer_string.toString());
try {
HttpResponse response = httpclient.execute(httpget);
InputStream is = response.getEntity().getContent();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(20);
int current = 0;
while ((current = bis.read()) != -1) {
baf.append((byte) current);
replyString = new String(baf.toByteArray());
} catch (Exception e) {
return replyString.trim();
private static ArrayList<FoursquareVenue> parseFoursquare(final String
response) {
ArrayList<FoursquareVenue> temp = new ArrayList<FoursquareVenue>();
try {
JSONObject jsonObject = new JSONObject(response);
if (jsonObject.has("response")) {
if (jsonObject.getJSONObject("response").has("venues")) {
JSONArray jsonArray =
for (int i = 0; i < jsonArray.length(); i++) {
FoursquareVenue poi = new FoursquareVenue();
if (jsonArray.getJSONObject(i).has("name")) {

if (jsonArray.getJSONObject(i).has("location"))
(jsonArray.getJSONObject(i).getJSONObject("location").has("address")) {
(jsonArray.getJSONObject(i).getJSONObject("location").has("city")) {

(jsonArray.getJSONObject(i).has("categories")) {
(jsonArray.getJSONObject(i).getJSONArray("categories").length() > 0) {

} catch (Exception e) {
return new ArrayList<FoursquareVenue>();
return temp;
Pavle <pavlex4@gmail.com>: Jun 04 10:56AM -0700

How to force kernel to send voltage from battery to usb port:
<http://forum.xda-developers.com/show....php?t=2691624> for my android???
kjohri <karuneshjohri@gmail.com>: Jun 04 05:18AM -0700

I am having the following environment:
Ubuntu Linux 16.04
Java 1.8.0_91
Android Studio 2.1.1
Android SDK Tools 25.1.7
Suddenly, Event Log shows, IllegalArgumentException: button doesn't exist 0.
The messages in the terminal, in which studio.sh was run, are,
[2224068] ERROR - llij.ide.plugins.PluginManager - button doesn't exist 0
java.lang.IllegalArgumentException: button doesn't exist 0
at java.awt.event.InputEvent.getMaskForButton(InputEvent.java:247)
at java.awt.LightweightDispatcher.isMouseGrab(Container.java:4486)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4511)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:650)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:381)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
[2224101] ERROR - llij.ide.plugins.PluginManager - Android Studio 2.1.1
Build #AI-143.2821654
[2224101] ERROR - llij.ide.plugins.PluginManager - JDK: 1.8.0_91
[2224101] ERROR - llij.ide.plugins.PluginManager - VM: Java HotSpot(TM)
64-Bit Server VM
[2224101] ERROR - llij.ide.plugins.PluginManager - Vendor: Oracle
[2224101] ERROR - llij.ide.plugins.PluginManager - OS: Linux
[2224101] ERROR - llij.ide.plugins.PluginManager - Last Action:
Any ideas?
Neilz <neilhornsey@gmail.com>: Jun 04 03:50AM -0700

Hi. I need a background task to run every minute. I have no need for a user
interface, although I understand that I must still declare a launcher
activity, which I can just finish() once I've set up my service.
I'm confused between the use of AlarmManager, Receivers and Services. So
far, I've scheduled a repeating alarm, which passes a class called
AlarmReceiver in its Intent. AlarmReceiver extends BroadcastReceiver, and
the onReceive() method successfully fires every minute, even if I kill the
activity, which is exactly what I want.
However, at no point am I using a class which extends Service or
IntentService, which when I look around at other people's examples, seems
to be what everyone does when they want a task to run as a background
service. Am I doing something wrong? Should I be calling a Service class
from my BroadcastReceiver instead of doing the work there?
Many thanks for any advice.
Mahanmukeshkannan Mukeshkannan <mahanmukeshkannan@gmail.com>: Jun 04 12:38AM -0700

I tried Mark Murphy its not working
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to android-developers+unsubscribe@googlegroups.com.

No comments:

Post a Comment