Vvjj
Tech Droid
Tips for Android Developers and my experiences with Android
Saturday, August 3, 2019
Saturday, March 28, 2015
PIN Screen Library for Android
Here's a simple and easy implementation for adding PIN lock support for your Android apps. The library can be themed with your app theme colors. It has smooth animations and vibrate cues when something's wrong.
To use this, you just have to write about 10 lines of code, including layouts and everything. It's so simple.
Steps to implement
- Add as dependency
<dependency>Android Studio:
<groupId>com.kbeanie</groupId>
<artifactId>pinscreenlibrary</artifactId>
<version>1.0.0</version>
</dependency>
compile 'com.kbeanie:pinscreenlibrary:1.0.0@aar'
- Add PinView to your layout file.
<com.kbeanie.pinscreenlibrary.views.PinView
android:id="@+id/pinView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
- Initialize PinView in two modes
pinView.setModeSetup(PinEntrySetupListener);
pinView.setModeAuthenticate(PinEntryAuthenticationListener)
And finally, handle the callbacks for all events. The complete source code for this project can be found on Github. Let me know if you have any queries or issues. I would be happy to resolve them.
Chapter:
Android,
PIN Screen,
Utilities
Thursday, November 20, 2014
New Sensors in Android 5.0 (Lollipop)
I found a few non-documented sensors on Lollipop (Android 5.0) on a Nexus 5.
Tried looking for them, but could't find any documentation on them on. Looks like they are mostly software sensors.
Here's the list that I have found. I have written a simple app that displays all the sensors and shows there values. Not to mention that, only for the ones that are documented. For the ones not documented, you can only see it's details.
There are only a few which appear on developer.android.com.
Here's an excerpt from the announcement.
Since there's no documentation, for some of them, I don't really know what they do. The only thing that gives you a clue is the sensor name. And, I don't know how to work with them as well.
Update: Seems, the documentation is coming soon. XDA picked this up.
Tried looking for them, but could't find any documentation on them on. Looks like they are mostly software sensors.
Here's the list that I have found. I have written a simple app that displays all the sensors and shows there values. Not to mention that, only for the ones that are documented. For the ones not documented, you can only see it's details.
There are only a few which appear on developer.android.com.
Here's an excerpt from the announcement.
New types of sensors
In Android 5.0, a new tilt detector sensor helps improve activity recognition on supported devices, and a heart rate sensor reports the heart rate of the person touching the device.
New interaction composite sensors are now available to detect special interactions such as a wake up gesture, a pick upgesture, and a glance gesture.
Since there's no documentation, for some of them, I don't really know what they do. The only thing that gives you a clue is the sensor name. And, I don't know how to work with them as well.
Tilt Detector
AMD Sensor (No idea, whats that)
RMD Sensor (No idea, whats that)
Basic Gestures Sensor
Tap Sensor
Facing Sensor
Tilt Sensor
Pedometer
Pedestrian Activity Monitor
Update: Seems, the documentation is coming soon. XDA picked this up.
Friday, June 20, 2014
Easy Swipe to Refresh in Android
Recently, Google released a new version of the Support Library, which has an interesting component. It's called SwipeRefreshLayout. With that, it's become a child's play to implement a quick Swipe-to-Refresh control for your apps.
A few things first
And there you go, a simple swipe to refresh usage for your Android apps. You can find the whole source code here.
A few things first
- Available only with android-support-v13. Which means that only apps target SDK level 13 and above can use this.
- It can only contain one scrollable direct child such as a ListView or a ScrollView.
That's all you need to know. Well.. A few things more, basically some xml and java code.
For this example, we use a ListView with some demo data. Once the list view is scrolled, we do some task, wait for sometime, and update the list view's adapter. Finally, ask the SwipeRefreshLayout to stop the progress indicator, since we are done with refreshing.
The layout file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}" >
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
The UI initialization
private void initializeViews() {The Refresh Task
refreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeLayout);
refreshLayout.setOnRefreshListener(this);
// The default colors for the progress bar are not so nice.
setColorSchemeForProgressBar();
ListView listView = (ListView) findViewById(R.id.listView);
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1);
adapter.addAll(getDemoData(5));
listView.setAdapter(adapter);
}
@OverrideThe Completion Work
public void onRefresh() {
Log.i(TAG, "Refresh Requested");
doRefresh();
}
// Fetch data and update listview's adapter
private void doRefresh() {
RefreshTask task = new RefreshTask();
task.execute((Void) null);
}
private void postRefreshComplete() {
// Stop the refresh animation
refreshLayout.setRefreshing(false);
// Update adapter with new data
adapter.clear();
adapter.addAll(getDemoData(new Random().nextInt(20)));
adapter.notifyDataSetChanged();
}
And there you go, a simple swipe to refresh usage for your Android apps. You can find the whole source code here.
Subscribe to:
Posts (Atom)