How to retrieve IMSI using PhoneGap? - mobile

I'm working on a cross platform mobile app using PhoneGap and I need to retrieve the IMSI code.
Here's the question: Is there any way to do this via PhoneGap?
I appreciate your comments.

hi for android we can find via native code , for phonegap we need to write a plugin, java code is given bellow
public String findDeviceID() {
String deviceID = null;
String serviceName = Context.TELEPHONY_SERVICE;
TelephonyManager m_telephonyManager = (TelephonyManager) getSystemService(serviceName);
int deviceType = m_telephonyManager.getPhoneType();
switch (deviceType) {
case (TelephonyManager.PHONE_TYPE_GSM):
break;
case (TelephonyManager.PHONE_TYPE_CDMA):
break;
case (TelephonyManager.PHONE_TYPE_NONE):
break;
default:
break;
}
deviceID = m_telephonyManager.getDeviceId();
return deviceID;
}
for creating phonegap plugin check this http://docs.phonegap.com/en/edge/guide_platforms_android_plugin.md.html#Android%20Plugins

Related

How to check if data connected or not in Android and ios using codenameOne

The following code is working fine for Android Devices bt it doesn't works in ios using codenameOne.
public static boolean checkNetwork(){
boolean online = false;
String net = NetworkManager.getInstance().getCurrentAccessPoint();
if (net == null || net == "" || net.equals(null)) {
online = false;
} else {
online = true;
}
return online;
}
Note : It seems No Connection Error Even data was connected to ios device
There is a CN1 library written by LittleMonkey that you can use to check connectivity. Search for connectivity in Codename One Extensions and download it to your project.
You can check for connection like this:
if (Connectivity.isConnected()) {
//we have some connection
} else {
// we have no connection
}
And you can check what type of connection
ConnectionState status = Connectivity.getConnectionState();
switch (status) {
case DISCONNECTED:
Log.p("Disconnected");
break;
case WIFI:
Log.p("On Wifi");
break;
case MOBILE:
Log.p("On Mobile Data");
break;
default:
//shouldn't be possible
}
Read more about this on GitHub.

Creating batch documents using pouchdb slows the webapp

I am trying to save documents using pouchdb's bulkSave() function.
However, when these documents are saved it starts to sync with master database using sync gateway & in doing so the webapp slows down and when I try to navigate to different tabs no content is displayed on that tab.
Below is an example of how the documents are being created:
for (var i = 0; i <= instances; i++) {
if (i > 0) {
advTask.startDate = new Date(new Date(advTask.startDate).setHours(new Date(advTask.startDate).getHours() + offset));
}
if (advTask.estimatedDurationUnit == 'Minutes') {
advTask = $Date.getAdvTaskEndTimeIfMinutes(advTask);
} else if (advTask.estimatedDurationUnit == 'Hours') {
advTask = $Date.getAdvTaskEndTimeIfHours(advTask);
} else if (advTask.estimatedDurationUnit == 'Days') {
advTask = $Date.getAdvTaskEndTimeIfDays(advTask);
}
if(new Date(advTask.endDate).getTime() >= new Date($scope.advTask.endDate).getTime()) {
// here save the task array using bulkSave() function
$db.bulkSave(tasks).then(function (res) {
$db.sync();
});
break;
}
advTask.startDate = $Date.toGMT(advTask.startDate);
advTask.endDate = $Date.toGMT(advTask.endDate);
var adv = angular.copy(advTask);
tasks.push(adv); // here pushing the documents to an array
offset = advTask.every;
}
Thanks in advance!
bulkSave is not a core PouchDB API; are you using a plugin?
Also one piece of advice I'd give is that Couchbase Sync Gateway does not have 100% support for PouchDB and is known to be problematic in some cases.
Another piece of advice is that running PouchDB in a web worker can prevent your UI thread from getting overloaded, which would fix the problem of tabs not showing up.
Do you have a live test case to demonstrate?

Dart VM itself implement `eval` in `dart:mirrors` and developers use it. Are planned to make this method public?

Here is code that use this eval method in Dart platform.
This is done via reflection.
runtime/lib/mirrors_impl.dart
_getFieldSlow(unwrapped) {
// ..... Skipped
var atPosition = unwrapped.indexOf('#');
if (atPosition == -1) {
// Public symbol.
f = _eval('(x) => x.$unwrapped', null);
} else {
// Private symbol.
var withoutKey = unwrapped.substring(0, atPosition);
var privateKey = unwrapped.substring(atPosition);
f = _eval('(x) => x.$withoutKey', privateKey);
}
// ..... Skipped
}
static _eval(expression, privateKey)
native "Mirrors_evalInLibraryWithPrivateKey";
runtime/lib/mirrors.cc
DEFINE_NATIVE_ENTRY(Mirrors_evalInLibraryWithPrivateKey, 2) {
GET_NON_NULL_NATIVE_ARGUMENT(String, expression, arguments->NativeArgAt(0));
GET_NATIVE_ARGUMENT(String, private_key, arguments->NativeArgAt(1));
const GrowableObjectArray& libraries =
GrowableObjectArray::Handle(isolate->object_store()->libraries());
const int num_libraries = libraries.Length();
Library& each_library = Library::Handle();
Library& ctxt_library = Library::Handle();
String& library_key = String::Handle();
if (library_key.IsNull()) {
ctxt_library = Library::CoreLibrary();
} else {
for (int i = 0; i < num_libraries; i++) {
each_library ^= libraries.At(i);
library_key = each_library.private_key();
if (library_key.Equals(private_key)) {
ctxt_library = each_library.raw();
break;
}
}
}
ASSERT(!ctxt_library.IsNull());
return ctxt_library.Evaluate(expression);
runtime/vm/bootstrap_natives.h
V(Mirrors_evalInLibraryWithPrivateKey, 2) \
P.S.
I ask question here becuase I cannot ask it at Dart mail lists.
P.S.
As we can see it static private method in mirrors_impl.dart:
static _eval(expression, privateKey) native "Mirrors_evalInLibraryWithPrivateKey";
Does anyone want that this method should be public? (this is not a question but just a thought aloud).
According to the Dart FAQ a pure string eval like that is not likely to make it into the language, even though other dynamic features will likely be added:
So, for example, Dart isn’t likely to support evaluating a string as
code in the current context, but it may support loading that code
dynamically into a new isolate. Dart isn’t likely to support adding
fields to a value, but it may (through a mirror system) support adding
fields to a class, and you can effectively add methods using
noSuchMethod(). Using these features will have a runtime cost; it’s
important to us to minimize the cost for programs that don’t use them.
This area is still under development, so we welcome your thoughts on
what you need from runtime dynamism.

Any way to programmatically get the FPS of a video?

I am currently working in this problem for hours now. I have to create a program that when user gets a video from a child window which accesses your hard disk drives, I have to get the frame rate and other properties from that video.
Here's a sample code of how I'm getting the videos and some of their properties.
SelectDirectoryWindow selectDirectoryWindow = (sender as SelectDirectoryWindow);
if (selectDirectoryWindow.DialogResult.GetValueOrDefault(false))
{
foreach (System.IO.FileInfo fileInfo in selectDirectoryWindow.VideoFiles)
{
VideoFileInfo videoFileInfo = new VideoFileInfo();
videoFileInfo.FileName = fileInfo.Name;
videoFileInfo.Path = fileInfo.FullName;
videoFileInfo.Extension = fileInfo.Extension;
videoFileInfo.FileSize = fileInfo.Length;
switch (videoFileInfo.Extension.ToUpper())
{
case ".WMV":
videoFileInfo.VideoFileType = Constants.VideoFileType.Wmv;
break;
case ".MOV":
videoFileInfo.VideoFileType = Constants.VideoFileType.ProResHq;
break;
case ".MPG":
videoFileInfo.VideoFileType = Constants.VideoFileType.Mpeg2;
break;
case ".ISM":
videoFileInfo.VideoFileType = Constants.VideoFileType.SmoothStreaming;
break;
case ".MP4":
videoFileInfo.VideoFileType = Constants.VideoFileType.iPad;
break;
default:
break;
}
Is there any way I can also get the frame rate, video duration and bit rate from this? What can I do to get the frame rate and bit rate? Thanks in advance.
I have found the answer. There is a ShellFile class on the Microsoft.WindowsAPICodePack.Shell. In there you can get the properties of the video, just give it the source of the file(filepath). And you can get anything from there.
Here's how I got the Frame Rate.
ShellFile shellFile = ShellFile.FromFilePath(sourceFile);
return (shellFile.Properties.System.Video.FrameRate.Value / 1000).ToString();

Is there anyway to know which user is calling the WCF Ria service on server side, using silverlight on clientside?

Is there anyway to know which user is calling the WCF Ria service on server side? Client side is siverlight, user has to be authenticated first in order to use the system.
I need to know which user is actually calling the service in my current task, thanks, i searched a lot, but seems no good findings.
Once the client side has successfully cleared your authentication challenge, the server can issue a token to the caller on the client side. In subsequent calls to the server, the client would send the token as one of the arguments and the server would verify the token and respond accordingly.
The token can contain a segment of information that identifies a given user, and implementing this will provide the functionality you are seeking.
The only guidelines for generating tokens is that they are unique, non-predictable and expirable. I have always encrypted my tokens so that they appear as gibberish, but step this is optional.
I've also done very much "googleing" and got a lot of headache before I got the solution.
I don't use RIA-Services - but it should be (hopefully) the same...:
The SL-Client sends a "login-request" to the server.
On the (WCF) server-side, I do the following (LoginData = Return-Info for SL-Client):
public LoginData LoginRequest() {
(...)
OperationContext context = OperationContext.Current;
System.ServiceModel.Channels.MessageProperties prp = context.IncomingMessageProperties;
System.ServiceModel.Channels.RemoteEndpointMessageProperty endPrp = prp[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty;
(...)
try {
clientIP = endPrp.Address;
System.Net.IPAddress ipAddress = System.Net.IPAddress.Parse(clientIP);
System.Net.IPHostEntry ipHostEntry = System.Net.Dns.GetHostEntry(ipAddress);
(...)
If you want to check the users WindowsPrincipal, you can do the following (securityGroup = server-side setting, which users can login):
(...)
switch (securityGroup) {
case SecurityGroup.AllClientsCanAccess: {
clientCanLogin = true;
} break;
case SecurityGroup.UseWindowsCredentials: {
if (OperationContext.Current.ServiceSecurityContext != null && OperationContext.Current.ServiceSecurityContext.WindowsIdentity != null) {
if (OperationContext.Current.ServiceSecurityContext.WindowsIdentity.IsAuthenticated) {
if (subSecurityInfo1 == true) { // only clients in specific roles can log in
bool userRoleFound = false;
WindowsPrincipal userPrincipal = new WindowsPrincipal(OperationContext.Current.ServiceSecurityContext.WindowsIdentity);
if (userPrincipal == null)
break;
foreach (string userRoleToPass in subSecurityList) { // subSecurityList = settings, which roles can pass
loginError.ErrorInfo += string.Format("{0}\n", userRoleToPass);
if (userPrincipal.IsInRole(userRoleToPass)) {
clientCanLogin = userRoleFound = true;
break;
}
}
if (userRoleFound) {
loginError.ErrorInfo = string.Empty;
break;
}
else {
loginError.ErrorNo = LoginErrorCodeNoEnum.UserIsNotInRole;
}
}
(...)
Hope it helps...

Resources