Offline Scorm Player for Android - android

I need to display and track the scorm content in a android application. I have search some post related to scorm player for mobile devices and it was closed too. I have already display the content using imsmanifest.xml
I am stuck with the tracking of LMS in the scorm file. After a long search, I found that I need to execute a JavaScript file for interacting with the scorm file and the application as Scorm_1.2 and Scorm_1.3 for old and newer version of scorm. I have executed the JavaScript too but its not communicating with the scorm file.
It always returning null value for the API object call from the JavaScript from scorm
if (win.API != null) {
return win.API; //It always null value
}
else {
if (win.frames.length > 0) {
for (var i = 0; i < win.frames.length; i++) {
if (win.frames[i] && win.frames[i].API != null) //Here too it comes null value
alert(win.frames[i].API);
return win.frames[i].API;
}
}
if (typeof(win.opener) != "undefined" && win.opener != null) {
return findAPI(win.opener);
}
if (win.parent != window && win.parent != win) {
return findAPI(win.parent);
}
return null;
}
Due to null value from the JavaScript its not communicating with the JavaScript in Scorm_1.2

SCORM is designed to be run from a web browser, not an app. The LMS must launch the course in a popup window or frameset, and the window/frameset must provide the SCORM API in the form of a JavaScript object.
Offline and mobile use cases (like yours) are one of the driving forces behind the Experience API (aka Tin Can).
As mentioned in other StackOverflow posts, there are commercial solutions that provide offline support, but technically they skirt the rules of the SCORM specification.

Related

How to Get info about phone calls

I have to develop a mobile application that monitors some info about calls, to limit users of a company to spend too much time with the phone near their ears. After x minutes, it should suggest to use earphones.
1st question: is it possible to monitor data like this? Phonecall time duration, start and end, if it's using earphones, internal or external speaker.. I mean, without using jailbreak or other hackings.
2nd question: is it possible doing this for IOS and Android?
3rt question: Do you know if Ionic has the capability to that?
Thank you.
Answering your questions:
Question1: Yes it's possible on Android. It's not possible on iOS. In Android, you can get call information if the user permits. You don't need to do jailbreaking or something. Whereas in iOS no way you can access call info.
Question2: Hope my first answer itself answers this. i.,e Android-Possible, iOS- not Possible
Question 3: AFAIK ionic framework is providing only basic details of Phone call time duration and contacts framework. You should explore more on Android to find out. Even if you use ionic framework you can't access this info at all on iPhone as native ios only not providing these details, we can't expect this from ionic framework.
For Android:
You can easily get the call history or incoming and outgoing call time.
So it is possible in android.
For iOS:
According to your question you want to limit the current calling time of phone near their ears.
So you also do it in iOS by some smartness.
In iOS 10 a new framework introduces for calling i.e. CallKit.
First, you have to get all contact in your application.
So user should call from your app.
For dialing also add the custom phone dialer.
By Some method of callKit you can do:
Add a call observer
#property ( nonatomic ) CXCallObserver *callObserver;
Initialize the call observer:
(instancetype)init
{
self = [super init];
if (self) {
//Initialize the call observer
_callObserver = [CXCallObserver new];
[_callObserver setDelegate:self queue:dispatch_get_main_queue()];
}
return self;
}
Add the delegate of call kit
#pragma mark - CXCallObserverDelegate
- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call{
[self callStateValue:call];
}
#pragma mark - Callkit State
- (void)callStateValue:(CXCall *)call {
NSLog(#"Call UIID: %#", call.UUID);
NSLog(#"hasEnded %#", call.hasEnded? #"YES":#"NO");
NSLog(#"isOutgoing %#", call.isOutgoing? #"YES":#"NO");
NSLog(#"isOnHold %#", call.isOnHold? #"YES":#"NO");
NSLog(#"hasConnected %#", call.hasConnected? #"YES":#"NO");
if (call == nil || call.hasEnded == YES) {
NSLog(#"CXCallState : Disconnected");
[timer1 invalidate];
NSLog(#"%ld",(long)self.duration);
if(self.duration>1)
self.duration=1;
}
if (call.isOutgoing == YES && call.hasConnected == NO) {
}
if (call.isOutgoing == NO && call.hasConnected == NO && call.hasEnded == NO && call != nil) {
self.duration = 0;
NSLog(#"CXCallState : Incoming");
NSLog(#"Call Details: %#",call);
}
if (call.hasConnected == YES && call.hasEnded == NO) {
NSLog(#"CXCallState : Connected");
timer1 = [NSTimer scheduledTimerWithTimeInterval:1.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
self.duration++;
NSLog(#"%ld",(long)self.duration);
}];
}
}
You can get the time duration and also add the condition After x minutes, it should suggest to use earphones.

How do I create a button to switch between mobile and desktop modes of my MVC site?

I have a MVC site that detects what device (mobile or desktop browser) is being used and displays the appropriate views: either MySite.cshtml or MySite.Mobile.cshtml. This is working fine. I would like to be able to have a button on the site that toggles between these two modes. How can I do that?
One of the things I'd like to do is make it able for a desktop user to view the mobile version. I would do this to demo this for a client. I could also see reasons a mobile user might want to see the desktop view (for example, they have a larger screen on their smart phone or their generic tablet is being recognized as a mobile device).
Here is how I choose the mobile or desktop view:
Global.asax.cs
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
BundleConfig.RegisterBundles(BundleTable.Bundles);
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
DeviceConfig.EvaluateDisplayMode();
}
}
DeviceConfig.cs
public static void EvaluateDisplayMode()
{
DisplayModeProvider.Instance.Modes.Insert(0,
new DefaultDisplayMode(DeviceTypePhone)
{
ContextCondition = (ctx => (
(ctx.GetOverriddenUserAgent() != null) &&
(
(ctx.GetOverriddenUserAgent().IndexOf("android", StringComparison.OrdinalIgnoreCase) >= 0) ||
(ctx.GetOverriddenUserAgent().IndexOf("iPhone", StringComparison.OrdinalIgnoreCase) >= 0) ||
(ctx.GetOverriddenUserAgent().IndexOf("Window Phone", StringComparison.OrdinalIgnoreCase) >= 0)||
(ctx.GetOverriddenUserAgent().IndexOf("Blackberry", StringComparison.OrdinalIgnoreCase) >= 0)
)
))
});
This creates it so a mobile device uses the view MySite.Mobile.cshtml and desktop sites use MySite.cshtml.
I can add a line of code to the end of the DeviceConfig.cs like this
||
(ctx.GetOverriddenUserAgent().IndexOf("webkit", StringComparison.OrdinalIgnoreCase) >= 0) ||
(ctx.GetOverriddenUserAgent().IndexOf("moz", StringComparison.OrdinalIgnoreCase) >= 0)
so that desktop browsers like Chrome will be recognized as mobile sites.
How can I create a button (or other control) to toggle between these two versions of the site?
So clicking a button called "Mobile Version" would call MySite.Mobile.cshtml and clicking a button called "Desktop Version" would call MySite.cshtml.
Here's a question that talks about this issue, but they seem to be implementing mobile sites a different way. I don't want to change the way I pick a mobile site at this point (the project is almost finished and the mobile site is working on mobile devices). However, I thought someone might be able to reconcile this suggestion with my question. I've tried and been able to do so.
Switching between a custom mobile display mode and desktop mode in ASP.NET MVC4
I have done something similar to this in the past. Have your "Switch to Desktop" point to an action that sets a bool session variable (let's say "FORCEDESKTOP") to true. This will be used to "force" the site into Desktop/Mobile mode.
Then, in your code that checks the viewer:
public static void EvaluateDisplayMode()
{
DisplayModeProvider.Instance.Modes.Insert(0,
new DefaultDisplayMode(DeviceTypePhone)
{
ContextCondition = (ctx => (
(ctx.GetOverriddenUserAgent() != null) &&
(
(ctx.GetOverriddenUserAgent().IndexOf("android", StringComparison.OrdinalIgnoreCase) >= 0) ||
(ctx.GetOverriddenUserAgent().IndexOf("iPhone", StringComparison.OrdinalIgnoreCase) >= 0) ||
(ctx.GetOverriddenUserAgent().IndexOf("Window Phone", StringComparison.OrdinalIgnoreCase) >= 0)||
(ctx.GetOverriddenUserAgent().IndexOf("Blackberry", StringComparison.OrdinalIgnoreCase) >= 0) ||
Convert.ToBoolean(HttpContext.Session["FORCEDESKTOP"]) != true
)
))
});
Then, when FORCEDESKTOP is true, you can switch the view code to allow the user to disable this again via that same action you used to set it.

Record and get volume to generate a waveform in Android using Cordova

I've been learning Cordova, now I am developing an app to record voice and I'd like to get the volume/Db/Amplitude of the sound being recorded.
I know that there's no oficial plugin by Cordova about this, so I searched and tested some plugins out there:
Wavesurfer.js:
It's easy and have a lot of features, but in android is not working, i don't know if the problem is webview or what (I have Android 4.1.2)
here are the details of my problem with this plugin:
https://github.com/katspaugh/wavesurfer.js/issues/341
MicVolume.js:
https://github.com/shukriadams/micVolume
I try this without success, I don't know exactly what's the problem but I think in this case it's in the cordova.exec
I can't find more plugins. Is there something else I can do or use, or maybe I am doing something wrong? I think it's strange that I canĀ“t find easy this kind of plugin, so maybe the solution it's starting to learn java from scratch? >:(
Thanks in advance.
You should use Crosswalk so that you can access the Web Audio API without a Cordova plugin. From there you could use something like this example:
http://tyleregeto.com/article/extracting-audio-data-with-the-web-audio-api
As of the current Crosswalk version, the Web Audio API is fully supported, and since you are using Cordova, you won't have any Cross-Origin issues to worry about (e.g. you will be on 'localhost' so there won't be any HTTPS problems).
I have built a Metronome in Angular that I used in a recent Ionic app with Crosswalk, and it works perfectly (even on a pretty bad XGODY device I used for testing). See the Gist below:
https://gist.github.com/MT--/ece6e388a693416aa7e7
I don't know how relevant this is since the question was asked over 1 year ago.
But it might help other people looking for an answer. MicVolume.js works but it is poorly documented, I spent a lot of time figuring it out. The following code should work:
function audioSuccessCallback(e) {
setInterval(function() {
micVolume.read(function(reading) {
console.log(reading.volume);
},
function(error){
console.log(error);
});
}, 200);
}
function audioErrorCallback(e) {
console.log(e);
}
micVolume.start(audioSuccessCallback, audioErrorCallback);
All you need to do is loop the micVolume.read() function and this will return you the "loudness" of the recording. Either through the internal mic or an external mic. Remember to call micVolume.start() after deviceready fires.
If you need to get the frequency of the sound, you could add following code to the plugin "MicVolumePlugin.java":
//Now we need to decode the PCM data using the Zero Crossings Method
int numCrossing = 0; //initialize your number of zero crossings to 0
for (int p = 0; p<bufferSize/4; p+=4) {
if (buffer[p]>0 && buffer[p+1]<=0) numCrossing++;
if (buffer[p]<0 && buffer[p+1]>=0) numCrossing++;
if (buffer[p+1]>0 && buffer[p+2]<=0) numCrossing++;
if (buffer[p+1]<0 && buffer[p+2]>=0) numCrossing++;
if (buffer[p+2]>0 && buffer[p+3]<=0) numCrossing++;
if (buffer[p+2]<0 && buffer[p+3]>=0) numCrossing++;
if (buffer[p+3]>0 && buffer[p+4]<=0) numCrossing++;
if (buffer[p+3]<0 && buffer[p+4]>=0) numCrossing++;
}//for p
for (int p=(bufferSize/4)*4;p<bufferSize-1;p++) {
if (buffer[p]>0 && buffer[p+1]<=0) numCrossing++;
if (buffer[p]<0 && buffer[p+1]>=0) numCrossing++;
}
// Set the audio Frequency to half the number of zero crossings, times the number of samples our buffersize is per second.
float frequency = (44100*4/bufferSize)*(numCrossing/2);
returnObj.put("frequency", frequency);
FFT is more accurate but it's a lot slower. This does the job pretty well. (I can't remember where I found this java code, but props to the one who wrote it!)

Does Android support window.location.replace or any equivalent?

It seems that the Android browser doesn't properly implement window.location.replace.
In most browsers, calling window.location.replace will replace the current URL with the URL passed to it.
When the user navigates somewhere else then clicks back, they'll be returned to the URL that was passed to window.location.replace, rather than the URL that they were at before window.location.replace was called.
The Android browser doesn't seem to implement this properly.
In the Android browser, the user will be directed back to the original URL rather than the one passed to window.location.replace.
You can test this for yourself here.
So is there any alternative way to re-write history in Android? Or will I just have to live without that feature, for Android users?
I had the same issue and ended up with code similar to chris suggestion, but I changed the if statement to use modernizr's feature detection.
If you're not using modernizr the code would look something like this:
if(!!(window.history && history.replaceState)){
window.history.replaceState({}, document.title, base + fragment);
} else {
location.replace(base + fragment);
}
Unless you have a specific reason for device detection, feature detection is preferred since it basically supports all devices, even future ones.
To make it work across all/most mobile platforms check out this link.
Shows how to handle redirect for Android, iPad and iPhone.
Android uses document.location whereas iOS supports window.location.replace
Will this work?
document.location.href = 'http://example.com/somePage.html';
You can try using the replaceState method on the history window.history
if (((navigator.userAgent.toLowerCase().indexOf('mozilla/5.0') > -1 && navigator.userAgent.toLowerCase().indexOf('android ') > -1 && navigator.userAgent.toLowerCase().indexOf('applewebkit') > -1) && !(navigator.userAgent.toLowerCase().indexOf('chrome') > -1))) {
window.history.replaceState({}, document.title, base + fragment);
} else {
location.replace(base + fragment);
}

android/iphone click to call in html

I am creating one HTML mobile website for android & ios device.
I know click to call for both.
ANDROID
2125551212
iOs
Live Support
Now, my problem is i have one webpage with click to call link and want that link work for both android / ios
Just use tel: it will work on iOS, android, blackbarry OS, windows and many more. Using this scheme will work on almost all mobile browsers on.
You have to recognize the client. Since different phones have different user agents, you can do something like this with JavaScript:
if (navigator.userAgent.indexOf("Android") != -1) {
txt = "2125551212";
} else if (navigator.userAgent.indexOf("iPhone") != -1) {
txt = "Live Support";
}
This works for me as well.
212-555-1212
The problem with this is it will break add-ons and extensions that people may use on desktop browsers.
The plain phone number will call on click for Android OS.
<p>212-555-1212</p>
You can also track this call with AdWords. I am working on getting it to work with Google Analytics.
In regards to MoyShe's post and not to steal her code (complements) I would add a conditional default for Desktop browsers and other as well using a default else statement.
if (navigator.userAgent.indexOf("Android") != -1) {
txt = "2125551212";
} else if (navigator.userAgent.indexOf("iPhone") != -1) {
txt = "Live Support";
}
<!--what about other devices OS-->
else {
txt = "<span><strong>Phone -</strong> 282-122-9627 ext.7877</span>";
}
That way desktop browsers users could also see a phone number as it would display a phone number by default if the device is not of the two handheld device queried.
I am not versed in android, blackberry, IOs, windows, etc...but I would also like to ask or point out my comment section.
<!--what about other devices OS-->
(For Newbs- the above line of commented code can be removed when pasting in the web page).
What about blackberry and all the other device OS's? Are they Android or IOs driven OS's? If not, additional code to specifically identify those devices would also need to be created and included in the (else if's) statements.
If I am correct in my unknown question, a Switch/Case statement might be cleaner and a better way to go.
as on
Msaccess Help Australia www.msaccess.com.au
You only want ordinary text showing on a PC browsers
so put this line in your page
<script type="text/javascript" src="javascript.js"></script>
and save the below in a file called javascript.js
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf ("mobile");
if (isAndroid)
{document.write('<a class="mobilesOnly" href="tel:++61476132591"> Click here to call tel:++61476132591</a>');}
else
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i)))
{document.write('<a class="mobilesOnly" href="tel:++61476132591"> Click here to call now: tel:++61476132591</a>');}
else
{document.write('Call ++61476132591') ;}
don't forget to change the number :)

Categories

Resources