Need to show browser through my application.
My application should go in background and browser should come in foreground.
int moduleHandle =
CodeModuleManager.getModuleHandle("net_rim_bb_browser_daemon");
if (moduleHandle > 0)
{
// Use the default browser application descriptor as the
// model descriptor.
ApplicationDescriptor[] browserDescriptors =
CodeModuleManager.getApplicationDescriptors(moduleHandle);
// Create the new application descriptor.
String[] args = {"url", url, null};
// Turn off auto restart (the original descriptor has it
// turned on) so we don't end up in a never ending loop of
// restarting the browser.
int flags = browserDescriptors[0].getFlags() ^
ApplicationDescriptor.FLAG_AUTO_RESTART;
ApplicationDescriptor newDescriptor =
new ApplicationDescriptor
(
browserDescriptors[0],
"BrowserPS",
args,
null,
-1,
null,
-1,
flags
);
// Run the application.
try
{
ApplicationManager.getApplicationManager().
runApplication(newDescriptor);
}
catch (ApplicationManagerException ame)
{
System.err.println(ame.toString());
}
}
This is my code it's working fine in simulator, but not on actual device.
any help.
Try like
BrowserSession browserSession = Browser.getDefaultSession();
browserSession.displayPage(URL);
Related
I have built the "NDIS 6.0 Filter Driver" WinDDK sample (ndislwf.sys), and built the BindView sample to install "NDIS 6.0 Filter Driver".
It installs OK, but it always bound to all Network Interfaces by default.
Is it possible to install NDIS Filter Driver and have it unbound from all Network Interfaces so then I could bind it only to certain interfaces ?
The code from BindView uses SetupCopyOEMInfW to copy the driver to the OemInfs :
if ( !SetupCopyOEMInfW(lpszInfFullPath,
DirWithDrive, // Other files are in the
// same dir. as primary INF
SPOST_PATH, // First param is path to INF
0, // Default copy style
NULL, // Name of the INF after
// it's copied to %windir%\inf
0, // Max buf. size for the above
NULL, // Required size if non-null
NULL) ) { // Optionally get the filename
// part of Inf name after it is copied.
dwError = GetLastError();
And then, uses INetCfgClassSetup::Install():
INetCfgClassSetup *pncClassSetup = NULL;
INetCfgComponent *pncc = NULL;
OBO_TOKEN OboToken;
HRESULT hr = S_OK;
//
// OBO_TOKEN specifies on whose behalf this
// component is being installed.
// Set it to OBO_USER so that szComponentId will be installed
// on behalf of the user.
//
ZeroMemory( &OboToken,
sizeof(OboToken) );
OboToken.Type = OBO_USER;
//
// Get component's setup class reference.
//
hr = pnc->QueryNetCfgClass ( pguidClass,
IID_INetCfgClassSetup,
(void**)&pncClassSetup );
if ( hr == S_OK ) {
hr = pncClassSetup->Install( szComponentId,
&OboToken,
0,
0, // Upgrade from build number.
NULL, // Answerfile name
NULL, // Answerfile section name
&pncc ); // Reference after the component
if ( S_OK == hr ) { // is installed.
//
// we don't need to use pncc (INetCfgComponent), release it
//
ReleaseRef( pncc );
}
ReleaseRef( pncClassSetup );
}
Recent versions of Windows 10 have a feature for this. Put this line into your INF:
HKR, Ndi\Interfaces, DisableDefaultBindings, 0x00010001, 1
Add that line in the same section that has the FilterMediaTypes directive.
That directive will create all new bindings to your filter in the disabled state. You can manually re-enable them in the same ways as before:
from the command-line (Set-NetAdapterBinding);
the GUI (run ncpa.cpl, open the adapter properties, check the box next to the filter driver); or
from INetCfg code (INetCfgBindingPath::Enable).
I'm using dlsym to load private APIs (required on iOS 9.3) :
handle = dlopen(CORETELPATH, RTLD_LAZY);
_CTServerConnectionCreate = dlsym(handle, "_CTServerConnectionCreate");
When I kill the app (swipe from bottom on multitask mode) and restart app, it crashes on the second line.
The handle is equal to NULL and I didn't succeed in loading the lib twice.
I tried to get the error with dlerror(), but it returns also NULL.
Does anybody got this issue ? How to resolve it ?
Edit :
Here is the full code ; with the if (handle != NULL) the app doesn't crashes, but private frameworks won't load also
#define CORETELPATH "/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony"
handle = dlopen(CORETELPATH, RTLD_LAZY);
NSLog(#"DL Error : %s", dlerror());
if (handle != NULL) {
_CTServerConnectionCreate = dlsym(handle, "_CTServerConnectionCreate");
CTResultConnection = _CTServerConnectionCreate(NULL, simMonitorCallback, NULL);
_CTServerConnectionAddToRunLoop = dlsym(handle, "_CTServerConnectionAddToRunLoop");
_CTServerConnectionAddToRunLoop(CTResultConnection, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
_CTServerConnectionRegisterForNotification = dlsym(handle, "_CTServerConnectionRegisterForNotification");
_CTServerConnectionUnregisterForNotification = dlsym(handle, "_CTServerConnectionUnregisterForNotification");
_CTServerConnectionRegisterForNotification(CTResultConnection, kCTSIMSupportSIMStatusChangeNotification);
_CTServerConnectionGetSIMStatus = dlsym(handle, "_CTServerConnectionGetSIMStatus");
_CTServerConnectionCopyMobileEquipmentInfo = dlsym(handle, "_CTServerConnectionCopyMobileEquipmentInfo");
}
It seems that changing Private API path to public fix the issue ; and the call to private APIs still works :
#define CORETELPATH "/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony"
When I use boost.asio, boost.thread and etc on iOS platform, the app crashed int release mode but works well int debug mode. I fix the release runtime bugs as I descibed at this.
My Question Is:
Why is everything ok in debug-mode? The answer seems to say that the crash is caused by thumb flag. The debug-mode compiler should use "thumb" flag as same as release mode, ant I wonder the app should also crash in debug-mode because of using thumb, which confuses me.
UPDATE:
Here is my code of using asio:
Params are declared as the private member of the CrossPlatformAPI:
boost::recursive_mutex m_mutex;
boost::asio::io_service m_ioService;
boost::scoped_ptr<boost::asio::io_service::work> m_idleWork;
boost::scoped_ptr<boost::thread> m_mainThread;
First, I post two async-tasks by calling CrossPlatformAPI::Init in the main thread:
int CrossPlatformAPI::Init(const P2PInitParam& oInitParam)
{
boost::recursive_mutex::scoped_lock lock(m_mutex);
m_idleWork.reset(new boost::asio::io_service::work(m_ioService));
m_mainThread.reset(new boost::thread(boost::bind( &boost::asio::io_service::run, &m_ioService)));
std::string strLog(oInitParam.szAppDataDir);
m_ioService.post(boost::bind( &CrossPlatformAPI::HandleLog, this, strLog));
m_ioService.post(boost::bind( &CrossPlatformAPI::HandleInit, this, oInitParam));
return 0;
}
Second, CrossPlatformAPI::HandleLog and CrossPlatformAPI::HandleInit handle the async-task:
void CrossPlatformAPI::HandleLog(std::string & log)
{
std::cout << log << std::endl;
}
void CrossPlatformAPI::HandleInit(P2PInitParam& oInitParam)
{
try
{
//Init
//...
}
catch (std::exception&)
{
}
return;
}
I have tried using boost:ref to wrap the binding param instead of binding directly, then the app doesn't crash. Why not? And what also confuses me is that if the bind param type is std::string, the param that the handle function received is incorrect when wrapped by std::ref. It seems that std::string without using std::ref works well: didn't crash and the value recived is correct, but not the sruct-type param, like P2PInitParam.
UPDATE2:
int CrossPlatformAPI::Init(const P2PInitParam& oInitParam)
{
boost::recursive_mutex::scoped_lock lock(m_mutex);
m_idleWork.reset(new boost::asio::io_service::work(m_ioService));
m_mainThread.reset(new boost::thread(boost::bind( &boost::asio::io_service::run, &m_ioService)));
std::string strLog(oInitParam.szAppDataDir);
m_ioService.post(boost::bind( &CrossPlatformAPI::HandleLog, this, boost::cref(strLog))); // OK
m_ioService.post(boost::bind( &CrossPlatformAPI::HandleInit, this, boost::cref(oInitParam))); // Crash
return 0;
}
void CrossPlatformAPI::HandleLog(const std::string& log)
{
std::cout << log << std::endl;
}
void CrossPlatformAPI::HandleInit(const P2PInitParam& oInitParam)
{
try
{
//Init
//...
}
catch (std::exception&)
{
}
return;
}
I'm trying to use vala to start an external application using GLib with spawn_command_line_sync().
According to the documentation (http://valadoc.org/#!api=glib-2.0/GLib.Process.spawn_sync) you can pass a string to store the output of the external application.
While this works fine when starting a script which prints a couple of lines, I need to call a program which will print the content of a binary file.
(for example "cat /usr/bin/apt-get")
Is there any way how I can receive the output of the external program not in a string, but in a DataStream or something like that ?
I'm planning to write the ouput of the external program to a file, so just calling "cat /usr/bin/apt-get > outputfile" would be an alternative (not as nice), but it doesn't seem to work.
Anyway I would prefer it to get some kind of Output Stream.
I would appreciate any help.
Code im using:
using GLib;
static void main(string[] args) {
string execute = "cat /usr/bin/apt-get";
string output = "out";
try {
GLib.Process.spawn_command_line_sync(execute, out output);
} catch (SpawnError e) {
stderr.printf("spawn error!");
stderr.printf(e.message);
}
stdout.printf("Output: %s\n", output);
}
GLib.Process.spawn_async_with_pipes will let you do just that. It spawns the processes and returns a file descriptor for each of stdout, stderr, and stdin. There's a sample of code in the ValaDoc on how to set up IOChannels to monitor the output.
Thanks for that, I must have overread spawn_async_with_pipes() returning ints and not strings.
Is there anything wrong with doing it this way ?
(besides the buffer size of 1)
using GLib;
static void main(string[] args) {
string[] argv = {"cat", "/usr/bin/apt-get"};
string[] envv = Environ.get();
int child_pid;
int child_stdin_fd;
int child_stdout_fd;
int child_stderr_fd;
try {
Process.spawn_async_with_pipes(
".",
argv,
envv,
SpawnFlags.SEARCH_PATH,
null,
out child_pid,
out child_stdin_fd,
out child_stdout_fd,
out child_stderr_fd);
} catch (SpawnError e) {
stderr.printf("spawn error!");
stderr.printf(e.message);
return;
}
FileStream filestream1 = FileStream.fdopen(child_stdout_fd, "r");
FileStream filestream2 = FileStream.open("./stdout", "w");
uint8 buf[1];
size_t t;
while ((t = filestream1.read(buf, 1)) != 0) {
filestream2.write(buf, 1);
}
}
I have required to disconnect outgoing call on specific number when apps launch.
Thanks !!
I use following code.
public void disconnect()
{
EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent( KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END, 0);
EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent( KeyCodeEvent.KEY_UP, (char) Keypad.KEY_END, 0);
EventInjector.invokeEvent(pressEndKey);
EventInjector.invokeEvent(releaseEndKey);
}