Tag: java

Android – How to get image file from Fresco disk cache?

I am using the Fresco library. I can’t find any related info in the Fresco documentation, how can I get an image file from Fresco’s disk cache?

Java – Android – Split Activity/Class into multiple files for better organization (solution)

I’m not PRO in JAVA , but I found myself of getting crazy with Android activities getting too large. After a few pages of code length I found myself of permanently scrolling back and forth! Not only OnClickhandlers can grow huge, just a lot of code tends to sum up in a bigger activity. Fragments […]

File descriptor leak example?

Is there any good example do demonstrate file descriptor leak in Android? I read somewhere that it occurs if we don’t close the streams for example FileInputStream or FileOutputStream but I could not find any good reference example which demonstrates it. Please share some blog/code snippet. thank you!

Turning on wifi tethering programmatically

Is it possible to turn on the wifi hotspot programmatically, to enable tethering? I’ve tried the code here and here. Both examples execute without exception, but when I look in the “Tethering & portable hotspot” section in the wifi settings, the tethering is still disabled. Is this only possible for internal Google apps? EDIT: I’m […]

Implement getMaxAmplitude for audioRecord

I am using audioRecord instead of mediarecorder in my app it’s working fine but I have a logic that depends highly on the maxamplitude which is really hard to obtain using the audiorecord here is what I am using when reading the buffer private void writeAudioDataToFile(){ byte data[] = new byte[bufferSize]; String filename = getTempFilename(); […]

How to update expandable list view when adapter's data changes

I have an activity that extends ExpandableListActivity. I use SimpleCursorTreeAdapter to fill ExpandableListView. My layout contains list view and empty view. On app start ExpandableListActivity automatically chooses the right view to display. My steps: App starts, there is no data. (empty view on the screen) Insert some data into db. Call adapter.notifyDataSetChanged(); But empty view […]

Make the plus sign a string in java

So I want the plus sign to be stored as a string and displayed to the screen later; so in this case I have String plusSign = “+”; but when I display the above on screen, I get a weird plus sign that has a circle around it. I am using the variable in an […]

Can priority inversion occur in Android

Priority inversion is a problem which can occur during scheduling of threads/processes, due to priorities associated with them. Priority inversion is a problematic scenario in scheduling in which a high priority task is indirectly preempted by a medium priority task effectively “inverting” the relative priorities of the two tasks – Wikipedia I wonder, can priority […]

RxJava pattern for requesting a remote Observable with a temporary cache

The use case is this: I want to temporarily cache the latest emitted expensive Observable response, but after it expires, return to the expensive source Observable and cache it again, etc. A pretty basic network cache scenario, but I’m really struggling to get it working. private Observable<String> getContentObservable() { // expensive upstream source (API, etc.) […]

Show event information with ExtendedCalendarView

I’m trying to create a custom calendar for show events and relative informations in my app. But I don’t know how to show this informations. That’s the code of the calendar: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ExtendedCalendarView calendar = (ExtendedCalendarView)findViewById(R.id.calendar); ContentValues values = new ContentValues(); values.put(CalendarProvider.COLOR, Event.COLOR_BLUE); values.put(CalendarProvider.DESCRIPTION, “Some Description”); values.put(CalendarProvider.LOCATION, “Some […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.