NullPointerException while setting mediaplayer in android studio - android-studio-3.0

I am new to android studio.
I was trying to make a media player but I receive an error:
java.lang.NullPointerException: Attempt to invoke virtual method
'void android.media.MediaPlayer.start()' on a null object reference
This is the error which is stopping from loading a media file
I have downloaded the media file from exact that location found in the tutorial.
My code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MediaPlayer mplayer=MediaPlayer.create(this, R.raw.k);
mplayer.start();

In your code mplayer variable is null, that is because R.raw.k is missing. Are you sure you have a file "r" in the raw resource? Follow this Media Player tutorial if you are just beginning with the media player.
Please place your media file in the raw directory and reference it using its correct name.

Related

Trying to use Naxam.Mapbox.iOS show blank page with Mapbox icon but no map

I've been trying to get the example going for Naxam.Mapbox.iOS as described here: https://blogs.naxam.net/using-mapbox-in-xamarin-ios-ffa9bdee13f4
I'm using Visual Studio/Xamarin 8.6.5 on my MacBook Pro with MacOS Catalina 10.15.4. I added NuGet Packages Naxam.Mapbox.iOS 5.4.0 and Xamarin.Essentials 1.5.3.2 to my project. I created an account at Mapbox.com and an access token for me to use in the project which I added as the MGLAccountManager.AccessToken property to the Info.plist file. The project has been created using the iOS Single View App template. Finally I added the --registrar:static argument to the Additional mtouch arguments in my iOS Build.
I added the first snippet of the blog post to my project as follows:
namespace MapboxSingleView
{
public partial class ViewController : UIViewController
{
public ViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
var map = new MGLMapView(View.Bounds, new NSUrl("mapbox://styles/naxamtest/cj5kin5x21li42soxdx3mb1yt"));
View.AddSubview(map);
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
}
}
}
Trying to run this in my simulator using Debug -> iPhone 11 iOS 13.5 shows a blank/white page with just the Mapbox logo in the bottom left corner but no actual map being displayed at all.
Trying without the NSUrl or adding the map's center & zoom level snippet as described doesn't help either. I tried contacting Naxam, but so far haven't received any response from them.
What did I miss?
The fact you can see the Mapbox logo indicates that you have done the installation correctly. The blank white page is usually down to a problem with the access token. You say you added
MGLAccountManager.AccessToken
to your info.plist file. The gif in the link on the tutorial page shows that if you are adding the entry in the info.plist file, then you should just add:
MGLAccountManager (with a value of <Your Mapbox access token>)
to that file. If you wish, instead, to add the access code in your code, then use:
MGLAccountManager.AccessToken = "<Your Mapbox access token>"
So it changes depending on if you want to enter your code in the info.plist file or as a line in your own code.

What is the best way to implement firebase crash report in iOS swift 3

Here incase of android firebase crash can be implemented in APPLICATION class like.. below example
(...here, if android app is crashed this overrriden method uncaughtException(Thread thread, Throwable e) is called where we report crash to firebase...)
So, I want to know if there is any better way to implement firebase crash in iOS swift 3 like this.
/** onCreate method of MainApplication.java */
#Override
public void onCreate() {
super.onCreate();
reportFirebaseCrash();
}
/** Report FirebaseCrash Exception if application crashed */
private void reportFirebaseCrash() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
#Override
public void uncaughtException(Thread thread, Throwable e) {
AppUtils.showLog(TAG, "reportFirebaseCrash");
FirebaseCrash.report(e);
}
});
}
Highly recommend you check out the Firebase docs — they're quite well done and should give you all the help you need to get started.
In particular, the simplest way to get up and running is to use the crash reporting pod:
pod 'Firebase/Crash'
Then you need to configure a FIRApp shared instance. Once that's set up (or if you have already), you need to configure your build system to upload crash reports. The docs link includes all the necessary details to do it, but tl;dr, you need to create a new Run Script build phase:
# Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
GOOGLE_APP_ID=1:my:app:id
# Replace the /Path/To/ServiceAccount.json with the path to the key you just downloaded
"${PODS_ROOT}"/FirebaseCrash/upload-sym "/Path/To/ServiceAccount.json"
Firebase also supports Bitcode in order to gather crash data from production users.

Convert recorded sound file to flac format (xamarin ios)

I record the sound of on iPhone using AvAudioRecorder (xamarin). How convert audio file to .FLAC format using C# (for google speech api) ?
There isn't a C# wav-to-flac converter right now.
You could simply use FLACiOS with wav-to-flac files embedded into a project in xcode.
Then use native binding of
public partial class NativeMethods
{
[DllImport("__Internal",
EntryPoint="convertWavToFlac",
CallingConvention = CallingConvention.Cdecl)]
public static extern int FlacEncode(
[MarshalAs(UnmanagedType.LPStr)] string wav_file,
[MarshalAs(UnmanagedType.LPStr)] string flac_file) ;
}
and just use bound native method to convert your wav to flac.
There are number of open source C# managed encoders, please check FlacBox or C# Flake. See also Discussion on the latter

PhoneGap Build Difficulty

I'm getting started with PhoneGap on iOS and not having much luck. My app is stuck on the splash screen and nothing is shown in Phoegap Build's console.
The screenshot at http://i.imgur.com/Ru9n3ET.png shows both my file structure and skeleton code. The only thing I see from the app is the alert of '1' called from body's onload event. Nothing else is shown. Is there a glaring mistake which is killing the app?
alert(1) is coming from javaScript and you has nothing to do with phonegap.
You would want to make sure that your code directory has the necessary API's that call Phonegap code. It would look like something below:
package com.news.newsfinder;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
You must have cordova.jar in your build path and cordova.js in your js directory.
Then your javascript code to call phonegap API's can become something like this.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
checkConnection();
}
function checkConnection() {
//code to check what type of internet connection a device is using, wifi, 2G, 3G...
}
The above code which has a package com.news.newsfinder will make an APP in play store like below:
http://play.google.com/store/apps/details?id=com.news.newsfinder

Error #1056 when embedding a SWF with a MovieClip containing another MovieClip in Actionscript for Mobile project using Flashbuilder 4.7

I have an Actionscript Mobile project in Flashbuilder 4.7 compiling for Android using AIR 3.4.
( AIR SDK location: C:\Program Files\Adobe\Adobe Flash Builder 4.7\eclipse\plugins\com.adobe.flash.compiler_4.7.0.345990\AIRSDK )
I recently resurrected the project from AIR 3.2 and have encountered a new run-time error.
I import a MovieClip asset (truck_anm_mc) from a SWF (originally published from Flash CS3 - in AS3, but republished using Flash CS6). The "truck_anm_mc" MovieClip contains another MovieClip with the instance name "Flick".
This is how it is imported:
public var _truck_anim :MovieClip;
[Embed(source='/assets/blue/animation004.swf#truck_anm_mc')]
public var TruckAnim :Class;
This is how it is used (I have commented out all further references to it - this is the only line of code using it, if I comment out this line the error disappears):
_truck_anim = new TruckAnim() as MovieClip;
This is the error:
ReferenceError: Error #1056: Cannot create property Flick on animation004_swf$915bbdce658b4869e6dc24efe65092b42084086601.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at animation004_swf$915bbdce658b4869e6dc24efe65092b42084086601()
...
Flick is on the timeline of truck_anm_mc.
If I delete Flick from the timeline, there is no error.
The error reports that the property Flick cannot be created on a Sprite, which would make sense to me if truck_anm_mc was a Sprite - but it is a MovieClip, which should be able to append arbitrary properties.
I have tried SWFs created with and without the Automatically declare stage instances option checked.
I am not using TLF or any RSLs. It is a very simple SWF just containing a MovieClip with another MovieClip motion tweened inside it on its timeline.
The MovieClips both use the MovieClip base document class and have their classes made dynamically by Flash. I tried making a document class for truck_anm_mc - and declaring Flick as a public var - but it did not avert the error.
I successfully used the same MovieClip asset by importing it using a different method. I exported the MovieClips in a SWC file and referenced that file from the Actionscript Mobile profile. Here is a useful tutorial on the method:
http://www.codeandvisual.com/2009/how-to-import-movieclips-into-a-flash-builder-actionscript-project/

Resources