[android-developers] Re: SQLite vs.File Based Storage for Battery Performance with Consistent Read/Write Operations.

2016-12-24 Thread Sal LO
https://goo.gl/Hioqtz

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/d18d9232-3388-4bc8-ba9f-d13365d883e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Meta: Changes to new-user moderation policy

2016-12-24 Thread Sal LO
https://goo.gl/Hioqtz

On Tuesday, December 1, 2015 at 1:28:00 AM UTC+2, Trevor Johns wrote:
>
> *As of today, new members to this group are able to post immediately, 
> without being subject to moderator approval.*
>
> Previously, posts from new members to this group would be held for 
> moderation. However, with the addition of Stack Overflow and Google+ as 
> popular discussion mediums, it's been difficult to find volunteer 
> moderators. As a result, the moderation queue has been showing signs of 
> neglect -- which means that new posts just aren't getting through.
>
> To address this, effective immediately, I've removed the moderation 
> restriction for new members.
>
> While this means that some spam may get through, this is necessary in 
> order to keep this group functioning properly going forward. If you do see 
> spam, simply report it through the Google Groups web UI. (Click on "Report 
> Abuse" next to the "Reply" button.) For larger/urgent issues, you can also 
> contact the group owners via email: 
> https://groups.google.com/forum/#!contactowner/android-developers
>
> -- 
> Trevor Johns
> Google Developer Programs, Android
> http://developer.android.com
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/57fba57e-8ab0-4b53-988f-010bd9938b1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] API Validation using the SlideShare API from Android

2016-12-24 Thread App TheSite
Hi,

I am trying to use SlideShare API for my android app. I am trying to make 
http request with parameters, and getting 

Failed API validation


I am using following code for GET request

HttpURLConnection urlConnection = null;

URL url = new URL("https://www.slideshare.net/api/2/get_slideshows_by_tag";);

urlConnection = (HttpsURLConnection) url.openConnection();

Long tsLong = System.currentTimeMillis()/1000L;

HttpClient httpClient = new DefaultHttpClient();

List nameValuePairs = new LinkedList();
nameValuePairs.add(new BasicNameValuePair("api_key",ClientSetup.SLIDESHARE_ID));
nameValuePairs.add(new BasicNameValuePair("ts", String.valueOf(tsLong)));
nameValuePairs.add(new 
BasicNameValuePair("hash",sha1Hash(ClientSetup.SLIDESHARE_SECRET+String.valueOf(tsLong;
nameValuePairs.add(new BasicNameValuePair("tag", "marketing"));


HttpGet httpget = new HttpGet(url+"?"+ URLEncodedUtils.format(nameValuePairs, 
"utf-8"));
HttpResponse response = httpClient.execute(httpget);


responseBody = EntityUtils.toString(response.getEntity());
Log.d (LOG_TAG, "response body is " + responseBody);




sha1Hash function is following



String sha1Hash( String toHash )
{
String hash = null;
try
{
MessageDigest digest = MessageDigest.getInstance( "SHA-1" );
byte[] bytes = toHash.getBytes("UTF-8");
digest.update(bytes, 0, bytes.length);
bytes = digest.digest();

// This is ~55x faster than looping and String.formating()
hash = bytesToHex( bytes );
}
catch( NoSuchAlgorithmException e )
{
e.printStackTrace();
}
catch( UnsupportedEncodingException e )
{
e.printStackTrace();
}
return hash;
}



Am I doing something wrong?


Thanks Grigor

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/fd8298d4-1f5d-4762-8101-59cc902e470f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] SQLite vs.File Based Storage for Battery Performance with Consistent Read/Write Operations.

2016-12-24 Thread Robert Simoes


In accordance with forum etiquette I did previously post this on SO, but 
I'd like to get a few more advanced Android developer thoughts.

I have a background service that runs all the time when screen is on, and 
every minute records the cycle time and whether it was a good or bad cycle. 

At the end of each day I take these counts of good and bad intervals and 
record it to a csv file.

For visual people like me:
   <--THE DAY ->
minutes:  1m1m1m1m1m1m1m 1m   1m  
   |-|-|-|-|-|-|-|-|-|Record
good  bad   good  good  good  bad   bad  good   bad   bad 


Currently I use *SharedPreferences *to store the good/bad count throughout 
the day, and write it to a file at the end of the day, but am becoming 
increasingly worried about the persistence of this (to my understanding) 
cached data [I also feel like I may be stretching it's or. 

I'm trying to decide between the following designs: 

*1. File Based:*
Use two temporary files (good interval, bad interval time), which I read 
and write values from at the end of each interval

File Based is simple and straight forward, but opening and closing streams 
every minute could be heavy.


*2. SQLite:*

Create a database with entries representing each day, and consistently 
update the entries after each interval end. 


SQLite would make things cleaner and feel like hacky, but I'm worried about 
the heaviness of keeping a DB connection open all the time and making 
write/read calls every minute


*From a battery performance perspective, which design choice is most 
optimal for ~500-5000 actions daily and why?*

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/3c2705eb-2da9-4fba-8f45-c6c8c1eebcb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Interact with menu from Presenter

2016-12-24 Thread mr. Bellski
Hello. Can't understand how i can manipulate with menu from Presenter. For 
example i have some rules to add menu item (for example ROLE), or i want to 
update text of menu item (badge) from background. I know that i can do all 
things in Activity, but Activiry is a View. 
So if follow MVP rules, all things which communicate with db, services and 
etc must be in presenter.
P.S. sry for my English.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/fd89d297-40ff-4960-8398-6924f80ed4a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Survey on Software Architectures

2016-12-24 Thread Mert Ozkaya
Dear All,

I am re-sharing my post since there are only a few contributors that I 
ccould found out so far :-(

We're conducting a survey on software architecture modelling whose link is 
http://bit.ly/2bGpSN4
The survey aims at better understanding the practical knowledge and 
experience of practitioners on software architecture modelling languages.
If you spend 3-7 mins to fill the  survey, we would be so grateful to you. 
Indeed, we imperatively need participants to contribute our research on 
software architectures.
If you know any potential participants, would you mind me requesting you to 
forward to survey to them?
Best,Mert

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/7b1f8ab0-0a18-4a28-92f6-51e3c0117a31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] SearchView with autocomplete via volley

2016-12-24 Thread Shekar Tippur
Hello,

I am trying to implement a generic fragment that contains a SearchView with 
autocomplete data coming from a external api.
I am having trouble populating the list.

Appreciate any pointers.

Here is my menu:



http://schemas.android.com/apk/res/android";

xmlns:app="http://schemas.android.com/apk/res-auto";>








http://schemas.android.com/apk/res/android";
xmlns:tools="http://schemas.android.com/tools";>







Fragment snippet:


@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Inflate the menu; this adds items to the action bar if it is present.

SearchManager searchManager = (SearchManager) 
getActivity().getSystemService(Context.SEARCH_SERVICE);

try {

getActivity().getMenuInflater().inflate(R.menu.drawer_view, menu);

mRefresh = menu.findItem(R.id.action_search);



//mListView.setTextFilterEnabled(true);
if (mRefresh != null) {

searchView = (SearchView) mRefresh.getActionView();
}


if (searchView != null) {

searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setIconified(false);
searchView.setSuggestionsAdapter(adapter);
searchView.setOnQueryTextListener(new 
SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// Toast like print
Log.d("SearchViewSubmit", "In searchView listener" + query);
if (!searchView.isIconified()) {
searchView.setIconified(true);
}
mRefresh.collapseActionView();
return false;
}


@Override
public boolean onQueryTextChange(String s) {

// Start volley search only of the first 3 characters are 
stored
if (s.length() >= 3) {
updateList(s);

return true;
}
mListView.clearTextFilter();

return false;
}

});
}
//return true;
}catch (Exception ex){
ex.printStackTrace();
}
   
}


// Volley request

public void updateList(String place) {
String input = "";

try {
input = URLEncoder.encode(place, "utf-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}

String output = "json";
url = AppConfig.HOST + AppConfig.GET_ITEMS + input;


JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, 
url,
null, new Response.Listener() {

@Override
public void onResponse(JSONObject response) {
try {
JSONArray ja = response.getJSONArray(TAG_RESULT);

String[] columnNames = {"item_name"};


// Filter data

// Trying out options. Trying to populate matrix cursor
mc = new MatrixCursor(columnNames);

String[] from = {"item_name"};
int[] to = {android.R.id.text1};
String[] tempStr = new String[1];

for (int i = 0; i < ja.length(); i++) {

JSONObject c = ja.getJSONObject(i);
String description = c.getString("name");
String id = c.getString("id");
Log.d("ItemName", description);
Log.d("ItemID", id);


tempStr[0]=description;
//tempStr[1]=description;
mc.addRow(tempStr);

}


   // Not sure if this approach is better
mListView.setAdapter(mAdapter = new ArrayAdapter(cTxt, 
android.R.layout.simple_list_item_1, tempStr));
mListView.setTextFilterEnabled(true);
mListView.setFilterText(description.toString());

// Or this
//adapter = new 
SimpleCursorAdapter(cTxt,android.R.layout.simple_list_item_1,mc,from,to,CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

//searchView.setSuggestionsAdapter(adapter);
} catch (Exception e) {
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});

// Submit to queue
HttpRequestQueue.getInstance(cTxt).addToRequestQueue(jsonObjReq);
}

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.