Monthly Archives: November 2017

How make row in Parse Unique using Parse CloudCode

In the Parse app database there is no option to make a key (object) unique. Usually you can chat using af find before adding a row but when you use .saveinbackground()  you cannot be sure.

Best solution is to add a beforeSave trigger on Parse Server using cloud code. I’m not a cloud code specialist so it took me quite a while to figure it out but using the code below you should be able to do this pretty quick.

This needs no modification of you app.

Add this (and adust to your needs) to you main.js and upload to Parse Server.

myObjectClass is the ‘table name’ in Parse.
myKey is the ‘field’ you want to make unique within your table (object)

Parse.Cloud.beforeSave("myObjectClass", function(request, response) {
    var myObject = request.object;
	if (myObject.isNew()){  // only check new records, else its a update
		var query = new Parse.Query("myObjectClass");
			success:function(number){ //record found, don't save
				//sResult = number;
				if (number > 0 ){
					response.error("Record already exists");
				} else {
			error:function(error){ // no record found -> save
    } else {

How to change text size of TabLayout Tabs in Android Studio

To change the size of the font 2 steps need to be done:

  1. Add as Style for the Tablayout
  2. Apply the style to the TabLayout in the XML

Find or create res -> values -> styles.xml

1. Add the Style to the XML

<style name="MyCustomTabText" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">12sp</item>

2. Apply Style

Find the Layout containing the TabLayout and add the style. The added line is bold.

    android:layout_height="wrap_content" />


How to Add Option / settings menu to android App


Add this to your mainactivity:

public boolean onCreateOptionsMenu(Menu menu){
    // Create menu
    // See onOptionItemSelected for actions when clicked

    Menu settingsMenu = menu;
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu);

    MenuItem settingsMenuLogin = settingsMenu.findItem(;

return true;


public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    if (id == {
        // add additional check
        Intent i = new Intent(getApplicationContext(), export.class);
    return super.onOptionsItemSelected(item);

and create an xml in res\menu like this:


<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android=""
        app:showAsAction="never" />