question

Rajani PV avatar image
Rajani PV asked

How to get home button long press dialog screen event and different action like app, settings and sleep... callback inside fire tv application ?

sleep-option.png


How to get home button long press dialog screen event and different action like app, settings and sleep... callback inside fire tv application ?

Animation

I tried executing the code below , able to see home button press action in fire tv gen3 device but not working in gen2 device .In addition to that unable to get the dialog event press action inside app.

<code>HomeWatcher mHomeWatcher =newHomeWatcher(this);
    mHomeWatcher.setOnHomePressedListener(newOnHomePressedListener(){@Overridepublicvoid onHomePressed(){// do something here...}@Overridepublicvoid onHomeLongPressed(){}});
    mHomeWatcher.startWatch();
<code>public class HomeWatcher {
static final String TAG = "HOME WATCHER";
private Context mContext;
private IntentFilter mFilter;
private OnHomePressedListener mListener;
private InnerReceiver mReceiver;

public HomeWatcher(Context context) {
    mContext = context;
    mFilter = new IntentFilter();
    mFilter.addAction(Intent.ACTION_SCREEN_OFF);
    mFilter.addAction(Settings.ACTION_HOME_SETTINGS);
    mFilter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
}

public void setOnHomePressedListener(OnHomePressedListener listener) {
    mListener = listener;
    mReceiver = new InnerReceiver();
}

public void startWatch() {
    if (mReceiver != null) {
        mContext.registerReceiver(mReceiver, mFilter);
    }
}

public void stopWatch() {
    try {
        if (mReceiver != null) {
            mContext.unregisterReceiver(mReceiver);
        }
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
}

class InnerReceiver extends BroadcastReceiver {
    final String SYSTEM_DIALOG_REASON_KEY = "reason";
    final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
    final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
    final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        Log.d(TAG,  action + ",reason:" + action);
        if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
            String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
            if (reason != null) {
                Log.d(TAG, "InnerReceiver" + action + ",reason:" + reason);
                if (mListener != null) {
                    if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
                        mListener.onHomePressed();
                    } else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
                        mListener.onHomeLongPressed();
                    } else if (reason.equals(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS)) {
                        mListener.onHomeLongPressed();
                    }
                }
            }
        } else if (action.equals(Intent.ACTION_SCREEN_OFF) ||action.equals(Settings.ACTION_HOME_SETTINGS)) {
            mListener.onHomePressed();
        }
    }
}<br>
fire tv
sleep-option.png (57.8 KiB)
1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Its a blocker issue for please appreciate the support...

0 Likes 0 ·

1 Answer

Levon@Amazon avatar image
Levon@Amazon answered

Hi Rajani,

Thanks for posting! No, you cannot get that event or customize that screen. That functionality is not exposed for 3rd party apps. Thanks!

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.