Audio no longer playing in background on iOS 6 in Phonegap project - audio

I need audio running in the background for my application. In versions before iOS 6 this worked perfectly by adding the
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
code to the appropriate .plist file, however this no longer works when deploying my phonegap project to iOS 6. How can I fix this in iOS 6?

In the MainController.h file change the following:
#import "MainViewController.h"
#import <AVFoundation/AVFoundation.h>
#implementation MainViewController
- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
}
return self;
}
I'm not sure if the following is necessary but I cleaned my project (CMD+ALT+K), recompiled the PhoneGap / Cordova Lib (change target and let it run to simulator) and (after changing the target again) compiled to the application once more and now it works!
Beware: it only works on Device, not on the simulator

Related

What is the proper syntax for using subcontrollers with Ufront?

In my main controller I followed the instructions in the Controller documentation and I have the following meta data:
#:route(GET, "/about/*")
var aboutController:AboutController;
Then in my AboutController file I have:
package controller;
import api.TestApi;
import api.PortfolioItem;
using ufront.MVC;
using ufront.web.result.AddClientActionResult;
class AboutController extends Controller
{
#:route(GET, "/graphicDesign")
public function graphicDesign()
{
// return new PartialViewResult({… etcetera
}
}
When I visit the /about/graphicDesign path in my browser, the PHP server generates an error:
PHP Fatal error: Call to a member function execute() on null in /Users/allan/Documents/Freelance/Confidant/Website/3d confidant site/ufront/www/lib/controller/HomeController.class.php on line 70
The PHP lines 69-71 have:
public function execute_aboutController() {
return $this->context->injector->_instantiate(_hx_qtype("controller.AboutController"))->execute();
}
So, do I need different syntax so that the controller instantiates properly?
fyi i upgraded to 3.4 i don't have the same issues.
yes remoting does not work but only when targeting php7 . in fact even when not targeting php7 and running in a php7 apache environment doesn't work either. also in works with Mamp & php 5.6.
i had no probs with sub controllers though.
my answer is . did you try on another php environment ?

How to show full compile error messages info in Checker FrameWork with line numbers etc

I just started using Checker Framework and have a problem that is exactly reproducible on one of the example projects from authors of this framework. This project is available here:
https://github.com/typetools/checker-framework/tree/master/docs/examples/GradleExamples
When i run this command from root:
>gradle compileJava
i receive this compilation output:
public static /*#Nullable*/ Object nullable = null;
^
required: #Initialized #NonNull Object
list.add(null); // error on this line
^
required: #Initialized #NonNull String
2 errors
:compileJava FAILED
As you can see there is no any information about where errors occur like class name, line number in code etc.
I did not find any information in their official manual about any compiler parameters that can change output format appropriately. I want error messages look like this:
~\GradleExample.java:33 error: ';' expected
UPDATE:
I achieve this behaviour on 3 machines:
OS: Microsoft Windows 7 x64 Ultimate SP1 [version 6.1.7601];
Java: 1.8.0_73;
Gradle: 2.14.
OS: Microsoft Windows 10 x64 Pro [version 10.0.14393];
Java: 1.8.0_121;
Gradle: 3.4.1.
OS: Microsoft Windows 7 x64 Ultimate SP1 [version 6.1.7601];
Java: 1.8.0_121;
Gradle: 3.4.1.
The absence of line numbers and class names is experienced only when running with Gradle. I also tried to run checker with Maven and with Javac from command line and it worked perfectly.
To configure Checker Framework with Gradle i followed steps from manual. There are 3 steps:
Download framework;
Unzip it to create a checker-framework directory;
Configure Gradle to include Checker Framework on the classpath.
As i understand, Gradle will do steps 1 and 2 automatically when providing needed Checker Framework's jars through dependency management. Nevertheless i tried both options:
dependency management:
I simply downloaded example project and executed "gradle compileJava" from root
of the GradleJava7Example project.
manually writing paths in gradle build file:
allprojects {
tasks.withType(JavaCompile).all { JavaCompile compile ->
compile.options.compilerArgs = [
'-processor', 'org.checkerframework.checker.nullness.NullnessChecker',
'-processorpath', "C:\\checker-framework-2.1.10\\checker\\dist\\checker.jar",
"-Xbootclasspath/p:C:\\checker-framework-2.1.10\\checker\\dist\\jdk8.jar",
'-classpath', 'C:\\checker-framework-2.1.10\\checker\\dist\\checker.jar;C:\\checker-framework-2.1.10\\checker\\dist\\javac.jar'
]
}
}
I've found a workaround. I'll explain it later, but now if somebody has the same problem, add this line to you JavaCompile tasks configuration:
allprojects {
tasks.withType(JavaCompile).all { JavaCompile compile ->
System.setProperty("line.separator", "\n") // <<<<<< add this line
compile.options.compilerArgs = [
'-processor', 'org.checkerframework.checker.nullness.NullnessChecker',
'-processorpath', "${configurations.checkerFramework.asPath}",
"-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}"
]
}
}
First of all i must say that problem was not in Checker Framework at all. I managed to reproduce the same behavior as mentioned in question without Checker Framework. I have created a little custom Annotation Processor. Here is the code:
#SupportedSourceVersion(value = SourceVersion.RELEASE_8)
#SupportedAnnotationTypes(value = {"*"})
public class MyProcessor extends AbstractProcessor{
#Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
String sepr = System.getProperty("line.separator");
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "[error code] " + sepr + " catched!!!");
return true;
}
}
As you can see, all it does is printing a message right away from start. Note that i used a line separator provided by java.lang.System class to split message. When i registered this processor and tried to run "gradle compileJava" from gradle project it produced the following output:
:compileJava
catched!!!
1 error
:compileJava FAILED
The property "line.separator" for Windows OS returns CR+LF: "\r\n". I don't know why Messager.printMessage(Diagnostic.Kind kind, CharSequence msg) has this behaviour, because when i type System.err.print("[error code] " + sepr + " catched!!!") instead, everything works fine (note also that this problem occur only when i use Gradle, if i run manually javac with all arguments or use Maven everyting is fine).
I found that if i substitude the provided by system separator with simple "\n" symbol compiler error messages are displayed correctly.
For now i choose this solution as a workaround.

TestFairy NSLogs on iOS10 for Cordova

I am new to test fairy and asked support but I did not hear from them so trying here.
The problem is that I cannot see the raw logs window within the session on the iOS app but I can see it when in android or when I run the app on the iPhone Simulator.
I followed the instructions to the letter to export the app as adhoc ecc...
Here is the api documentation.
https://docs.testfairy.com/FAQ.html
Oh I should also mention that I have a cordova / ionic app.
Thanks in advance.
Ok, so thanks to TestFairy amazing support especially #VijaySharma here is the solution for those in need.
Find the .pch header file in Platforms > iOS > MyApp > MyApp-Prefix.pch
In the header add the following.
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "TestFairy.h"
#define NSLog(s, ...) do { NSLog(s, ##__VA_ARGS__); TFLog(s, ##__VA_ARGS__); } while (0)
#endif
Save the file and Rebuild the app.
Also if you want to show all the logs make sure you have this plugin: https://github.com/apache/cordova-plugin-console
All set!

How to configure Appium and Android Studio?

Hi am very new in appium , I have run my first test case (Java with TestNG) using eclipse but now i want switch to Android Studio. Please provide me step by step process to add jar's and other things into Android Studio
I recommend you to use IntelliJ IDEA. You can create project with gradle where you can insert dependencies, but you can include easly .jars by File -> Project structure -> Libraries -> (+) -> Java and then select your .jar file.
IntelliJ IDEA got testNG already installed so you don't have to install it.
For testing all you need are gson-2.2.2, java-client-4.0.0, selenium-java-2.53.1 jars.
To connect with your device use class
public class Setup {
private final String DEVICE_NAME = "deviceName";
private final String PLATFORM_NAME = "platformName";
private final String PLATFORM_VERSION = "platformVersion";
private final String APP_PACKAGE = "appPackage";
private final String APP_ACTIVITY = "appActivity";
private String deviceName = "Android SDK built for x86"; //device name can be found in device settings
private String platformName = "Android";
private String platformVersion = "6.0"; //version of your android
private String port = "4723"; //port from Appium server
private String url;
private String getIp() throws UnknownHostException {
InetAddress ip = InetAddress.getLocalHost();
return ip.getHostAddress();
}
public AndroidDriver establishConnection() throws MalformedURLException {
try {
url = String.format("http://%s:%s/wd/hub", getIp(), port);
} catch (UnknownHostException e) {
e.printStackTrace();
}
DesiredCapabilities capability = new DesiredCapabilities();
capability.setCapability(DEVICE_NAME, deviceName);
capability.setCapability(PLATFORM_NAME, platformName);
capability.setCapability(PLATFORM_VERSION, platformVersion);
capability.setCapability(APP_PACKAGE, "my.app.package");
capability.setCapability(APP_ACTIVITY, "my.app.activity");
return new AndroidDriver(new URL(url), capability);
}
}
After this you can create new class with #BeforeClass where you can create object of Setup class, call establishConnection(); and initialize driver and test your app UI with #Test methods. Don't forget to install .apk first on your device :)
You need for Appium setup in Android Studio -
Appium Server
Appium Java Client jar
Selenium client jars
You can view this Video Step By Step Appium Setup with Android Studio
Regards,
Anuja
Android Studio 3.1.2, Min SDK 21. If Min SDK lower, you can try using a lower version of appium java-client.
Add Java client Jar through gradle in the your gradle build file dependencies section. Make sure that the
client version you pick is usable for your minimum/target android SDKs.
dependencies {
testImplementation 'io.appium:java-client:4.1.2'
}
Your android project has a java folder for your source files. Search for a folder that has the word (test) in parentheses. Create a java file in there. If you place it in the (androidTest) folder, you will run into various problems.
Add your unit test code to that file. In my case I was using JUnit.
Install appium server through your preferred means. You can find install executables through https://github.com/appium/appium-desktop/releases/ or you can dabble with nodejs and its package manager.
Configure appium server's settings to match those of your unit test (i.e the ports should match).
Start appium server.
Right click on your test and click the Run 'XXXXX' where XXXXX is the name of your class.
Select the emulator/physical device you desire.
There is no need to manually download jars and add them as I was seeing in some tutorials. If you follow the steps above, you'll have what you need.
I did all the steps but I rebuild wasn't successful, then I got this as a solution:
the android {...} closure in the build.gradle for your app module to resolve the issue:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
and all the errors are solved. my java version was 10 and it didn't work!!

Windows App Certification Kit hangs

I have developed windows 10 App and uploaded that to windows store. However, I wanted to apply Windows Certification App Kit. The testing hangs during these two stages;
Direct3D trim after suspend
In progress...
UTF-8 file encoding
In progress...
I don't use any of those features in my app, but I don't understand why it should hang during process?
Thank you!
I ran into this exact same issue:
"Direct3D trim after suspend In progress... UTF-8 file encoding In progress..."
Problem was that I didn't try to run the Release Version locally first. It didn't run because I used preprocessor directives like so:
public static LicenseInformation licenseInformation = null;
...
#if DEBUG
...
...
licenseInformation = CurrentAppSimulator.LicenseInformation;
#else
licenseInformation = CurrentApp.LicenseInformation;
#endif
"CurrentApp" did cause an exception.. I use code like this now:
#if DEBUG
...
...
licenseInformation = CurrentAppSimulator.LicenseInformation;
#else
try
{
licenseInformation = CurrentApp.LicenseInformation;
}
catch (Exception)
{
}
#endif
And when working with the licenseInformation somewhere I check if it is not null before I use it...
I also found some other issues (warnings) in my code by using "Run Code Analysis on Solution"..
So in my case it was a problem with my code.
WACK "Hangs" because it is waiting for the app to start.The problem occurs if you use packages that internally use native code. An example is SQLite (Written in C++).
SQLite for Universal Windows Platform requires this Directive to be included in Properties/Default.rd.xml. Otherwise the external code will throw exceptions when your app is run in native mode (Release build in Visual Studio).
<Type Name="System.Collections.ArrayList" Dynamic="Required All" />
For details about this directive and EntityFramework.Sqlite (EF7), see: https://docs.efproject.net/en/latest/platforms/uwp/getting-started.html

Resources