本文整理汇总了C++中CJNIIntent::getIntExtra方法的典型用法代码示例。如果您正苦于以下问题:C++ CJNIIntent::getIntExtra方法的具体用法?C++ CJNIIntent::getIntExtra怎么用?C++ CJNIIntent::getIntExtra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CJNIIntent
的用法示例。
在下文中一共展示了CJNIIntent::getIntExtra方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onReceive
void CXBMCApp::onReceive(CJNIIntent intent)
{
std::string action = intent.getAction();
android_printf("CXBMCApp::onReceive Got intent. Action: %s", action.c_str());
if (action == "android.intent.action.BATTERY_CHANGED")
m_batteryLevel = intent.getIntExtra("level",-1);
else if (action == "android.intent.action.DREAMING_STOPPED" || action == "android.intent.action.SCREEN_ON")
{
if (HasFocus())
g_application.WakeUpScreenSaverAndDPMS();
}
else if (action == "android.intent.action.HEADSET_PLUG" || action == "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED")
{
bool newstate;
if (action == "android.intent.action.HEADSET_PLUG")
newstate = (intent.getIntExtra("state", 0) != 0);
else
newstate = (intent.getIntExtra("android.bluetooth.profile.extra.STATE", 0) == 2 /* STATE_CONNECTED */);
if (newstate != m_headsetPlugged)
{
m_headsetPlugged = newstate;
CAEFactory::DeviceChange();
}
}
}
示例2: onReceive
void CXBMCApp::onReceive(CJNIIntent intent)
{
std::string action = intent.getAction();
android_printf("CXBMCApp::onReceive Got intent. Action: %s", action.c_str());
if (action == "android.intent.action.BATTERY_CHANGED")
m_batteryLevel = intent.getIntExtra("level",-1);
else if (action == "android.intent.action.DREAMING_STOPPED" || action == "android.intent.action.SCREEN_ON")
{
if (HasFocus())
g_application.WakeUpScreenSaverAndDPMS();
}
else if (action == "android.intent.action.HEADSET_PLUG" || action == "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED")
{
bool newstate;
if (action == "android.intent.action.HEADSET_PLUG")
newstate = (intent.getIntExtra("state", 0) != 0);
else
newstate = (intent.getIntExtra("android.bluetooth.profile.extra.STATE", 0) == 2 /* STATE_CONNECTED */);
if (newstate != m_headsetPlugged)
{
m_headsetPlugged = newstate;
CAEFactory::DeviceChange();
}
}
else if (action == "android.intent.action.MEDIA_BUTTON")
{
CJNIKeyEvent keyevt = (CJNIKeyEvent)intent.getParcelableExtra(CJNIIntent::EXTRA_KEY_EVENT);
int keycode = keyevt.getKeyCode();
bool up = (keyevt.getAction() == CJNIKeyEvent::ACTION_UP);
CLog::Log(LOGINFO, "Got MEDIA_BUTTON intent: %d, up:%s", keycode, up ? "true" : "false");
if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_RECORD)
CAndroidKey::XBMC_Key(keycode, XBMCK_RECORD, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_EJECT)
CAndroidKey::XBMC_Key(keycode, XBMCK_EJECT, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_FAST_FORWARD)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_FASTFORWARD, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_NEXT)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_NEXT_TRACK, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_PAUSE)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_PLAY_PAUSE, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_PLAY)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_PLAY_PAUSE, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_PLAY_PAUSE)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_PLAY_PAUSE, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_PREVIOUS)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_PREV_TRACK, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_REWIND)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_REWIND, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_STOP)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_STOP, 0, 0, up);
}
}
示例3: onReceive
void CXBMCApp::onReceive(CJNIIntent intent)
{
std::string action = intent.getAction();
android_printf("CXBMCApp::onReceive Got intent. Action: %s", action.c_str());
if (action == "android.intent.action.BATTERY_CHANGED")
m_batteryLevel = intent.getIntExtra("level",-1);
}
示例4: onReceive
void CXBMCApp::onReceive(CJNIIntent intent)
{
std::string action = intent.getAction();
android_printf("CXBMCApp::onReceive Got intent. Action: %s", action.c_str());
if (action == "android.intent.action.BATTERY_CHANGED")
m_batteryLevel = intent.getIntExtra("level",-1);
else if (action == "android.intent.action.DREAMING_STOPPED" || action == "android.intent.action.SCREEN_ON")
if (HasFocus())
g_application.WakeUpScreenSaverAndDPMS();
}
示例5: ReceiveNetworkEvent
bool CAndroidNetworkManager::ReceiveNetworkEvent(INetworkEventsCallback *callback, const NetworkEventDataPtr data)
{
// All actions are event-driven. Android broadcasts connection events in the
// form of subscribed events from XBMCApp. See CXBMCApp::onReceive
const CJNIIntent intent(*boost::static_pointer_cast<const CJNIIntent>(data));
std::string action = intent.getAction();
CLog::Log(LOGDEBUG, "NetworkManager: Received event: %s",action.c_str());
if (action == CJNIWifiManager::NETWORK_STATE_CHANGED_ACTION)
{
GetEthernetConnection();
GetWifiAccessPoints();
GetCurrentWifiConnection();
if(m_currentWifi.get() && m_currentWifi->GetState() == NETWORK_CONNECTION_STATE_CONNECTED)
{
// Call the callback before setting the event so that the connection list
// Is updated before leaving the wifi dialog
callback->OnConnectionListChange(GetConnections());
m_wifiConnectionEvent.Set();
}
else
callback->OnConnectionListChange(GetConnections());
}
else if(action == CJNIConnectivityManager::CONNECTIVITY_ACTION)
{
const CJNINetworkInfo newNetworkInfo = intent.getParcelableExtra(CJNIWifiManager::EXTRA_NETWORK_INFO);
if (newNetworkInfo)
{
int type = newNetworkInfo.getType();
std::string typeName = newNetworkInfo.getTypeName();
std::string stateName = newNetworkInfo.getState().name();
if (type == CJNIConnectivityManager::TYPE_ETHERNET)
{
// This one is simple, just pass the new status along to the connection
GetEthernetConnection();
if (m_ethernetConnection.get())
{
if(m_ethernetConnection->GetState() == NETWORK_CONNECTION_STATE_CONNECTED)
{
callback->OnConnectionListChange(GetConnections());
m_ethernetConnectionEvent.Set();
}
else
callback->OnConnectionListChange(GetConnections());
}
}
else
{
GetWifiAccessPoints();
GetCurrentWifiConnection();
callback->OnConnectionListChange(GetConnections());
}
}
}
else if (action == CJNIWifiManager::SCAN_RESULTS_AVAILABLE_ACTION)
{
GetWifiAccessPoints();
callback->OnConnectionListChange(GetConnections());
}
else if (action == CJNIWifiManager::SUPPLICANT_STATE_CHANGED_ACTION)
{
int error = intent.getIntExtra(CJNIWifiManager::EXTRA_SUPPLICANT_ERROR, 0);
if (error == 1)
{
CLog::Log(LOGDEBUG, "NetworkManager: authentication failed");
GetCurrentWifiConnection();
callback->OnConnectionListChange(GetConnections());
m_currentWifi->OnAuthFailed();
m_wifiConnectionEvent.Set();
}
}
else if (action == CJNIWifiManager::RSSI_CHANGED_ACTION)
{
if (!m_currentWifi.get())
GetCurrentWifiConnection();
if (m_currentWifi.get())
{
int newRSSI = intent.getIntExtra(CJNIWifiManager::EXTRA_NEW_RSSI, 0);
m_currentWifi->SetStrength(newRSSI);
callback->OnConnectionChange(m_currentWifi);
}
}
return true;
}
示例6: onReceive
void CXBMCApp::onReceive(CJNIIntent intent)
{
std::string action = intent.getAction();
CLog::Log(LOGDEBUG, "CXBMCApp::onReceive - Got intent. Action: %s", action.c_str());
if (action == "android.intent.action.BATTERY_CHANGED")
m_batteryLevel = intent.getIntExtra("level",-1);
else if (action == "android.intent.action.DREAMING_STOPPED" || action == "android.intent.action.SCREEN_ON")
{
if (HasFocus())
g_application.WakeUpScreenSaverAndDPMS();
}
else if (action == "android.intent.action.HEADSET_PLUG" ||
action == "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED")
{
bool newstate = m_headsetPlugged;
if (action == "android.intent.action.HEADSET_PLUG")
newstate = (intent.getIntExtra("state", 0) != 0);
else if (action == "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED")
newstate = (intent.getIntExtra("android.bluetooth.profile.extra.STATE", 0) == 2 /* STATE_CONNECTED */);
if (newstate != m_headsetPlugged)
{
m_headsetPlugged = newstate;
CServiceBroker::GetActiveAE()->DeviceChange();
}
}
else if (action == "android.media.action.HDMI_AUDIO_PLUG")
{
bool newstate;
newstate = (intent.getIntExtra("android.media.extra.AUDIO_PLUG_STATE", 0) != 0);
if (newstate != m_hdmiPlugged)
{
CLog::Log(LOGDEBUG, "-- HDMI state: %s", newstate ? "on" : "off");
m_hdmiPlugged = newstate;
if (m_hdmiPlugged != m_hdmiReportedState)
{
if (g_application.IsInitialized())
{
CWinSystemBase* winSystem = CServiceBroker::GetWinSystem();
if (winSystem && dynamic_cast<CWinSystemAndroid*>(winSystem))
dynamic_cast<CWinSystemAndroid*>(winSystem)->SetHDMIState(m_hdmiPlugged);
m_hdmiReportedState = m_hdmiPlugged;
}
}
}
}
else if (action == "android.intent.action.SCREEN_OFF")
{
if (m_playback_state & PLAYBACK_STATE_VIDEO)
CApplicationMessenger::GetInstance().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_STOP)));
}
else if (action == "android.intent.action.MEDIA_BUTTON")
{
if (m_playback_state == PLAYBACK_STATE_STOPPED)
{
CLog::Log(LOGINFO, "Ignore MEDIA_BUTTON intent: no media playing");
return;
}
CJNIKeyEvent keyevt = (CJNIKeyEvent)intent.getParcelableExtra(CJNIIntent::EXTRA_KEY_EVENT);
int keycode = keyevt.getKeyCode();
bool up = (keyevt.getAction() == CJNIKeyEvent::ACTION_UP);
CLog::Log(LOGINFO, "Got MEDIA_BUTTON intent: %d, up:%s", keycode, up ? "true" : "false");
if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_RECORD)
CAndroidKey::XBMC_Key(keycode, XBMCK_RECORD, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_EJECT)
CAndroidKey::XBMC_Key(keycode, XBMCK_EJECT, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_FAST_FORWARD)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_FASTFORWARD, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_NEXT)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_NEXT_TRACK, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_PAUSE)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_PLAY_PAUSE, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_PLAY)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_PLAY_PAUSE, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_PLAY_PAUSE)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_PLAY_PAUSE, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_PREVIOUS)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_PREV_TRACK, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_REWIND)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_REWIND, 0, 0, up);
else if (keycode == CJNIKeyEvent::KEYCODE_MEDIA_STOP)
CAndroidKey::XBMC_Key(keycode, XBMCK_MEDIA_STOP, 0, 0, up);
}
else if (action == "android.net.conn.CONNECTIVITY_CHANGE")
{
if (g_application.IsInitialized())
{
CNetworkBase& net = CServiceBroker::GetNetwork();
CNetworkAndroid* netdroid = static_cast<CNetworkAndroid*>(&net);
netdroid->RetrieveInterfaces();
}
}
}