Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.view.ViewConfiguration;

import java.lang.reflect.Field;

public class Main {
    /**
     * Force overflow menu in samsung devices
     *
     * @param context The activity context.
     */
    public static void forceOverFlowMenu(Context context) {
        try {
            ViewConfiguration config = ViewConfiguration.get(context);
            Field menuKeyFields = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");

            if (menuKeyFields != null) {
                menuKeyFields.setAccessible(true);
                menuKeyFields.setBoolean(config, false);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}