String uuid = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
byte[] bytes = uuid.getBytes();
byte[] id = new byte[] {bytes[0], bytes[bytes.length / 2], bytes[bytes.length - 1]};
Displays a vertically-scrollable collection of views, where each view is positioned immediatelybelow the previous view in the list. For a more modern, flexible, and performant approach to displaying lists, use RecyclerView
public int getCount()
public View getView(int i, View view, ViewGroup viewGroup)
public static interface Listener {
public void onClick(int id);
}
cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onClick(product.id);
}
}
});
productsAdapter.setListener(new ProductsAdapter.Listener() {
public void onClick(int id) {
Intent intent = new Intent(MainActivity.this, InnerActivity.class);
intent.putExtra(InnerActivity.EXTRA_PRODUCT, id);
startActivity(intent);
}
});
final Cursor cursor = db.query ("products", null, "id = ?", new String[] { id }, null, null, null);
if((Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(this))) {
new NotificationPopupView(intent, pushNotification.getTitle(), pushNotification.getBody());
}
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />