Failure delivering result ResultInfo{who=null, request=1000, result=-1, data=Intent { (has extras) }} to activity java.lang.IllegalStateException - illegalstateexception

I have this function that records the screen. It works from Android 6 to 9. From Andriod 10, issues start to arrise.
private void initRecorder() {
try {
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
//VIDEO RATES
mediaRecorder.setVideoEncodingBitRate(512 * 1000);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); //Be very careful with the Encoder, it should match the VideoSource
mediaRecorder.setVideoSize(DISPLAY_WIDTH, DISPLAY_HEIGHT);
mediaRecorder.setVideoFrameRate(30);
//AUDIO RATES
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB);
mediaRecorder.setAudioEncodingBitRate(96000);
mediaRecorder.setAudioSamplingRate(44100);
videoUri = FilingSystem.Companion.getCompletedLectures()
+ "/" + fileName + "_Dub_Records_" + new SimpleDateFormat("dd-MM-yyyy-hh-mm-ss")
.format(new Date()) +
".mp4";
compressedVideo = FilingSystem.Companion.getCompletedLectures()
+ "/" + fileName + "_Compressed_Dub_Records_" + new SimpleDateFormat("dd-MM-yyyy-hh-mm-ss")
.format(new Date()) +
".mp4";
int rotation = getWindowManager().getDefaultDisplay().getRotation();
int orientation = ORIENTATION.get(rotation + 90);
mediaRecorder.setOrientationHint(orientation);
mediaRecorder.prepare();
surface = mediaRecorder.getSurface();
} catch (IOException e) {
e.printStackTrace();
}
}
From the function, you can see that the mediaRecorder is already prepared. So now when I start it in the onActivityResult since I have to get a couple of permissions for this, it works for Android 6 to Android 9. But in Android 10, I get the error
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1000, result=-1, data=Intent { (has extras) }} to activity {com.example.ynot/com.example.ynot.Activities.LectureStudio}: java.lang.IllegalStateException
at android.app.ActivityThread.deliverResults(ActivityThread.java:5589)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5630)

Related

MS Azure sends Notification to only 10 devices

I am Using Azure Notification hub when sending push notifications to GCM and APN what I notice on the production it is only send to the first 10 registered devices and other new register device cant receive messages despite it is already registered on GCM . what i need is to send to all registered devices and they are round 600 devices.
public class Notifications
{
public static Notifications Instance = new Notifications();
public NotificationHubClient Hub { get; set; }
private Notifications()
{
string NotificationHubConnectionString = WebConfigurationManager.AppSettings["NotificationHubConnectionString"];
string NotificationHubPath = WebConfigurationManager.AppSettings["NotificationHubPath"];
Hub = NotificationHubClient.CreateClientFromConnectionString(NotificationHubConnectionString, NotificationHubPath, false);
}
public static async void SendNotificationAsync(string Message, string Type, string ID, string Date, string Summery, string Location, string Risk)
{
string to_tag = Type.Replace(" ", string.Empty);
try
{
var notif = "{ \"data\" : {\"message\":\"" + Message + "\",\"type\":\"" + Type + "\",\"ID\":\"" + ID + "\",\"Date\":\"" + Date + "\",\"Summery\":\"" + Summery + "\",\"Risk\":\"" + Risk + "\",\"Location\":\"" + Location + "\"" + ", \"sound\" : \"default\"}}";
var outcome = await Notifications.Instance.Hub.SendGcmNativeNotificationAsync(notif);
string msg = string.Format("This Notification: " + Message + " has been delivered to this number [" + outcome.Success.ToString() + "] of android Mobiles");
Logger.LogMessage(msg, EventLogEntryType.Information);
}
catch (Exception ex)
{
string msg = string.Format("Coudn't send notification to android mobiles");
Logger.LogMessage(msg, EventLogEntryType.Error);
Logger.LogException(ex, EventLogEntryType.Error);
}
try
{
var alert = "{\"aps\":{\"alert\":\"" + Message + "\",\"type\":\"" + Type + "\",\"ID\":\"" + ID + "\",\"Date\":\"" + Date + "\",\"Summery\":\"" + Summery + "\",\"Risk\":\"" + Risk + "\",\"location\":\"" + Location + "\" " + ", \"sound\" : \"default\"}}";
var outcome = await Notifications.Instance.Hub.SendAppleNativeNotificationAsync(alert, to_tag);
string msg = string.Format("This Notification: " + Message + " has been delivered to this number ["+ outcome.Success.ToString() +"] of IOS Mobiles");
Logger.LogMessage(msg, EventLogEntryType.Information);
}
catch (Exception ex)
{
string msg = string.Format("Coudn't send notification to IOS mobiles");
Logger.LogMessage(msg, EventLogEntryType.Error);
Logger.LogException(ex, EventLogEntryType.Error);
}
}
I am assuming you are using the built-in testing tool in the Notification Hubs blade in the Azure Portal or Visual Studio.
This is by design - a test notification from there will go to 10 random devices. You will need to have a real backend sending notifications in order to propagate to all devices that are registered.
Details are outlined here.
Note that the use of this property is heavily throttled and so you
must only use this in dev/test environment with limited set of
registrations. We only send debug notifications to 10 devices. We also
have a limit of processing debug sends to be 10 per minute.
Check for this line:
bool enableTestSend = true;
NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(connString, hubName, enableTestSend);
In order to deliver for more than 10 devices, you need to make sure that you are not using EnableTestSend.

PushSharp for APNS works on local server but not on azure

I am using push sharp in a ASP.NET web api server. on my local computer everything works like a charm for GCM and APNS but once uploaded to azure only the GCM messages work. the APNS is not working, not throwing exceptions nothing. I have traces in every event the push broker throws but no trace message is called. not even the message queued...
Here is my initialization code:
public PushNotificationManager()
{
_pushService = new PushBroker();
_pushService.OnChannelCreated += OnChannelCreated;
_pushService.OnChannelDestroyed += OnChannelDestroyed;
_pushService.OnChannelException += OnChannelException;
_pushService.OnDeviceSubscriptionChanged += OnDeciveSubscriptionChanged;
_pushService.OnDeviceSubscriptionExpired += OnDeviceSubscriptionExpired;
_pushService.OnNotificationFailed += OnNorificationFailed;
_pushService.OnNotificationRequeue += OnNotificationQueued;
_pushService.OnNotificationSent += OnNOtificationSend;
_pushService.OnServiceException += OnServiceException;
InitAndroidPushService();
InitApplePushService();
}
private void InitApplePushService()
{
try
{
string appDataPath = HttpContext.Current.Server.MapPath("~/app_data");
//***** Development Server *****//
//string file = Path.Combine(appDataPath, "PushSharp.PushCert.Development.p12");
//var appleCert = File.ReadAllBytes(file);
// _applePushService = new ApplePushService(new ApplePushChannelSettings(false, appleCert, "XXXXXXX"));
//***** Production Server *****//
string file = Path.Combine(appDataPath, "PushSharp.PushCert.Production.p12");
var appleCert = File.ReadAllBytes(file);
_pushService.RegisterAppleService(new ApplePushChannelSettings(true, appleCert, "XXXXXX"));
Trace.TraceInformation("ApplePushService initialized succesfully");
}
catch (Exception e)
{
Trace.TraceError("Error initializing ApplePushService : " + e);
throw;
}
}
private void InitAndroidPushService()
{
try
{
_pushService.RegisterGcmService(new GcmPushChannelSettings("XXXXXX", "XXXXXX",
"XXXXX"));
Trace.TraceInformation("GooglePushService initialized succesfully");
}
catch (Exception e)
{
Trace.TraceError("Error initializing AndroidPushService : " + e);
}
}
Has anyone enountered such a thing?

Trying to play audio on Nokia C3, results in : Failed to fetch media data

I am currently working on a project that uses Manager.createPlayer(InputStream is, String mimeType) to create an audio player.
The audio player works perfectly on the emulator. On a Nokia C3 it is able to play an audio/mpeg track after the app starts, but fails when an attempt is made to play the same/other audio again. On prefetch a message, "failed to fetch media data" is caught.
When opening the player for the first time it is taken through the normal lifecycle: realize,prefetch,start.
After the track is finished it is: stopped,deallocated,closed . The player is even set to null, before the process is repeated for another audio track.
Any ideas?
Here is a sample of the code used to create the player.
public static Player play(PlayerListener listener, InputStream is, String[] mimeTypes) {
Player player = null;
for (int i = 0; i < mimeTypes.length; i++) {
try {
player = Manager.createPlayer(is, mimeTypes[i]);
player.realize();
player.prefetch();
player.addPlayerListener(listener);
player.start();
Log.write("started - " + mimeTypes[i]);
break;
} catch (Exception e) {
Log.write("player fail (" + mimeTypes[i] + "): " + e.getMessage());
player = null;
} catch (Throwable e) {
Log.write("player fail (" + mimeTypes[i] + "): " + e.getMessage());
player = null;
}
}
return player;
}
It seems that the answer is that the file size of the MP3 I am trying to play is too large. By lowering the size the problem solved itself.
From 2MB to 150kb.
If anyone could shed some light on why this would happen, it would be very greatly appreciated.

Invalid Cross Exception on Schedule Agent when working on isolated storage

I am working with a Windows Phone Schedule Agent and I am trying to update the picture name after sync the problem is that I am getting an invalid cross exception when on this function at line "BitmapImage bmp = new BitmapImage();" and really don’t understand why.
void UpdateSyncPictureName(int AsyncStatus, int AticketID, int AsyncID, int ApictureID, int TsyncStatus = 0, int TsyncID = 0)
{
string filename = AsyncStatus + "-" + AticketID + "-" + AsyncID + "-" + ApictureID;
using (IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication())
{
if (ISF.FileExists(filename))
{
BitmapImage bmp = new BitmapImage();
using (IsolatedStorageFileStream isoStream =
ISF.OpenFile(filename, System.IO.FileMode.Open))
{
bmp.SetSource(isoStream);
}
ISF.DeleteFile(filename);
WriteableBitmap Wbmp = new WriteableBitmap(bmp);
using (IsolatedStorageFileStream isoStream =
ISF.OpenFile(TsyncStatus + "-" + AticketID + "-" + TsyncID + "-" + ApictureID, System.IO.FileMode.Create))
{
Extensions.SaveJpeg(Wbmp, isoStream,
Wbmp.PixelWidth,
Wbmp.PixelHeight,
0, 100);
}
}
}
}
The issue arises from the fact that BitmapImage cannot be instantiated outside of the UI thread. You can fix this issue by wrapping your calls in a Dispatcher Invoke call.
However, you need to make sure that you call NotifyComplete correctly. As such you may need to put NotifyComplete in the Dispatcher call.
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
UpdateSyncPictureName(...);
NotifyComplete();
});

LWUIT4IO (v1.5) ConnectionRequest's readResponse() Issue - Nokia SDK 2.0

I have been porting an existing J2ME mobile app, that allows users to view archived news videos, to the latest Nokia SDK 2.0 platform for Series 40 full-touch devices.
I am using both the LWUIT and LWUIT4IO technologies for the UI and Network functionalities of the application respectively.
The app has been tested to work on the S40 5th Edition SDK platform emulator. Extending LWUIT4IO's ConnectionRequest class and utilizing LWUIT's XMLParser, the app can successfully send a HTTP request and get the expected response data from a web service that basically returns an XML-formatted type of feed (containing necessary metadata for the video) (Here's the URL of the web service: http://nokiamusic.myxph.com/nokianewsfeed.aspx?format=3gp)
But for some reason, this is not the case when trying to run the app on the latest Nokia SDK 2.0 platform. It throws a java.lang.NullPointerException upon trying to parse (XMLParser.parse()) the InputStream response of the web service. When I trace the Network Traffic Monitor of the emulator of the corresponding Request sent and Response received - 0 bytes were returned as content despite a successful response status 200. Apparently the XMLParser object has nothing to parse in the first place.
I am hoping that you can somehow shed light on this issue or share any related resolutions, or help me further refine the problem.
Posted below is the code of the SegmentService class (a sub-class of LWUIT's ConnectionRequest) that connects to the webservice and processes the XML response:
public class SegmentService extends ConnectionRequest implements ParserCallback {
private Vector segments;
private Video segment;
public SegmentService(String backend) {
String slash = backend.endsWith("/") ? "" : "/";
setPost(false);
setUrl(backend + slash + "nokianewsfeed.aspx");
addArgument("format", "3gp");
}
public void setDateFilter(String date) {
System.out.println(date);
addArgument("date", date);
}
private Video getCurrent() {
if (segment == null) {
segment = new Video();
}
return segment;
}
protected void readResponse(InputStream input) throws IOException {
InputStreamReader i = new InputStreamReader(input, "UTF-8");
XMLParser xmlparser = new XMLParser();
System.out.println("Parsing the xml...");
Element element = xmlparser.parse(i);
System.out.println("Root " + element.getTagName());
int max = element.getNumChildren();
System.out.println("Number of children: " + max);
segments = new Vector();
for (int c = 0; c < max; c++) {
Element e = element.getChildAt(c);
System.out.println("segment " + c);
int len = e.getNumChildren();
System.out.println("Number of children: " + len);
for (int d=0; d<len; d++) {
Element s = e.getChildAt(d);
String property = s.getTagName();
System.out.println("key: " + property);
String value = (s.getNumChildren()>0) ? s.getChildAt(0).getText() : null;
System.out.println("value: " + value);
if (property.equals("title")) {
getCurrent().setTitle(value);
} else if (property.equals("description")) {
getCurrent().setDescription(value);
} else if (property.equals("videourl")) {
getCurrent().setVideoUrl(value);
} else if (property.equals("thumburl")) {
getCurrent().setThumbUrl(value);
} else if (property.equals("adurl")) {
getCurrent().setAdUrl(value);
} else if (property.equals("publishdate")) {
getCurrent().setPublishDate(value);
} else if (property.equals("category")) {
getCurrent().setCategory(value);
} else if (property.equals("weburl")) {
getCurrent().setWebUrl(value);
} else if (property.equals("thumburl2")) {
getCurrent().setThumb210(value);
} else if (property.equals("thumburl4")) {
getCurrent().setThumb40(value);
}
}
if (segment != null) {
segments.addElement(segment);
segment = null;
}
}
fireResponseListener(new NetworkEvent(this, segments));
}
public boolean parsingError(int errorId, String tag, String attribute, String value, String description) {
System.out.println(errorId);
System.out.println(tag);
System.out.println(value);
System.out.println(description);
return true;
}
}

Resources