In case You had problem with:
Error:Could not find com.android.tools.build:gradle:2.2.0.
Searched in the following locations:
Don’t forget modify root build.gradle and add
It would look like this:
All what we need is to make few steps:
- Add in our project this line to output in log current path to database
Log.d(TAG, "onCreate db: " + context.getDatabasePath("mydatabase.db"));
- Create simple batch command to pull database (afik root is no needed)
adb pull "/data/data/com.example.app/databases/mydatabase.db" mydatabase_%date%.db.sqlite
- Download SQLiteManager to firefox, run it, open our sqlite database
Interesting solution found on stackoverflow.
In terminal, in current folder we write:
for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")
Here is an simple example how to use regex in notepad++ with reusing selected match variables.
For example we have special code for simulating gcm notifications. We would like to see it in pretty style.
To achieve this we must to move all elements with minus to the new lines. How to do it? Here is the solution.
We have this string:
adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE -c com.example.android.debug -n com.example.android.google.debug/com.example.android.gcm.GcmBroadcastReceiver --es "aaa" "123" --es "mmm" "bla bla bla" --es "sss" "321" --es "from" "111" --es "type" "yesterday" --es "collapse_key" "do_not_collapse"
By using bellow command in notepad++:
We get the quite pretty result:
adb shell am broadcast
--es "aaa" "123"
--es "mmm" "bla bla bla"
--es "sss" "321"
--es "from" "111"
--es "type" "yesterday"
--es "collapse_key" "do_not_collapse"
Here is a little help to remove from our logcat some logs we don’t want like: dalvikvm or OpenGL
All what you need is to click in top right corner of logcat, select our package name and click Edit Filter Configuration
Then in the field called Log Tag regex You need insert this
^((?!(?:dalvikvm|OpenGLRenderer)).)*$ which means you don’t want any log which contains dalvivm or OpenGLRenderer. If You want add another word to ignore list just insert inside of regex
Here is short and quite (imho) understanding part of code:
AlarmManager alarmManager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(getActivity(), MyReceiver.class);
intent.setAction(MyReceiver.ACTION_ALARM_RECEIVER);//my custom string action name
PendingIntent pendingIntent = PendingIntent.getBroadcast(getActivity(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), aroundInterval, pendingIntent);//first start will start asap
#1 – first we are getting alarm service. We create own intention and setting own action to it to be able handle in onReceive(), in our receiver class. Then the intention is putting into pendingIntent. The complete pendingIntent is used by alarmManager for a start.
I used System.currentTimeMillis() because I wanted start repeating asap.
I used flag PendingIntent.FLAG_CANCEL_CURRENT for pendingIntent but it might be also PendingIntent.FLAG_UPDATE_CURRENT. It is important to use the same flag everywhere, but when you want stop it, you use PendingIntent.FLAG_NO_CREATE. I will write about it later.
Number 1001 in pendingIntent was used just to be know that our intention has unique ID.
Continue reading “Working example of setting alarm with repeating stuff, checking if alarm was set with pendingIntent”
During my one day project for a client I had to use (I hate it) android’s ratingbar component. One of the pointed task in project was to use a bit smaller object with 5 stars than it is as default. What is more it had to be place it in every item in listview.
So what’s the problem? “All you have to do is to use param
” – I thought. But it has not been the final solution yet..
Continue reading “Smaller ratingboard with clickable area”
Hi, today I was working on MultiSelectListPreference in PreferenceFragment screen. I was going to have multi select list where user would be able select items. Each selected item would be describing specific shortcut from my app to OP desktop.
After about half an hour I found out how to restore MultiSelectListPreference with all default items.
Continue reading “Clearing items in MultiSelectListPreference – solution”
During my graduation work I had to use navigation drawer for menu list. What is more, I also needed pull to refresh layout. Both items are very sensitive and its order matters where to put them. You might be in situation where you think which one should be in which one. So during rebuilding layout with that two items first I moved pull to refresh layout up, to be a root layout. This showed me unpredictable result.
I was able swipe down to refresh even when I had already opened drawer…
Continue reading “Android NavigationDrawer not handling setOnItemClickListener- nothing happens – solution”
I have been working for my graduation work on layout `pull to refresh`, called now.. SwipeRefreshLayout. It was connected with NavigationDrawerFragment.
During tests over that two things I discovered I was not able to scroll down my list without calling refresh. I found very interesting solution on stackoverflow. Answer was posted by @Cabezas. Thank You!
Continue reading “Pull to refresh in project, disabling refresh when we want to scroll down”