Android PresetReverb not working (Kotlin) - android

Doesn't add reverb effect to mediaplayer.
Added permission to the manifest. Checked if the device supports effects.
Check device:
D/Constraints: Loudness Enhancer, type: fe3199be-aed0-413f-87bb-11260eb63cf1
D/Constraints: Multichannel Downmix To Stereo, type: 381e49cc-a858-4aa2-87f6-e8388e7601b2
D/Constraints: Visualizer, type: e46b26a0-dddd-11db-8afd-0002a5d5c51b
D/Constraints: Insert Preset Reverb, type: 47382d60-ddd8-11db-bf3a-0002a5d5c51b
D/Constraints: Auxiliary Preset Reverb, type: 47382d60-ddd8-11db-bf3a-0002a5d5c51b
D/Constraints: Insert Environmental Reverb, type: c2e5d5f0-94bd-4763-9cac-4e234d06839e
D/Constraints: Auxiliary Environmental Reverb, type: c2e5d5f0-94bd-4763-9cac-4e234d06839e
D/Constraints: Volume, type: 09e8ede0-ddde-11db-b4f6-0002a5d5c51b
D/Constraints: Equalizer, type: 0bed4300-ddd6-11db-8f34-0002a5d5c51b
D/Constraints: Virtualizer, type: 37cc2c00-dddd-11db-8577-0002a5d5c51b
D/Constraints: Dynamic Bass Boost, type: 0634f220-ddd4-11db-a0fc-0002a5d5c51b
private var player: MediaPlayer ?= null
player = MediaPlayer.create(context, R.raw.r2);
val mReverb = PresetReverb(0, 0)
mReverb.preset = PresetReverb.PRESET_LARGEROOM
mReverb.enabled = true
player?.attachAuxEffect(mReverb.id)
player?.setAuxEffectSendLevel(1.0f)
player?.start()
There are no error messages in Logcat

Related

Capacitor text-to-speech API not working on android

I am getting this error whenever I try to execute the TextToSpeech.speak() function from #capacitor-community/text-to-speech#0.2.3:
Uncaught (in promise) Error: Not supported on this device.
at n.value (29.a169ec33.chunk.js:formatted:3022)
at n.<anonymous> (29.a169ec33.chunk.js:formatted:2842)
at c (26.902cd79a.chunk.js:2)
at Generator._invoke (26.902cd79a.chunk.js:2)
at Generator.next (26.902cd79a.chunk.js:2)
at 29.a169ec33.chunk.js:formatted:2816
at new Promise (<anonymous>)
at l (29.a169ec33.chunk.js:formatted:2793)
at n.value (29.a169ec33.chunk.js:formatted:2836)
at 29.a169ec33.chunk.js:formatted:4997
Here is my code below:
import { TextToSpeech } from '#capacitor-community/text-to-speech';
const androidSpeak = async () => {
await TextToSpeech.speak({
text: 'This is a sample text.',
locale: 'en_US',
pitchRate: 1.0,
speechRate: 1.0,
volume: 1.0,
category: 'ambient',
});
};
Whenever I trigger the function it gives me the error above. Anyone experienced it before?
Modules:
#capacitor/android: ^2.4.2
#capacitor-community/text-to-speech: ^0.2.3
https://github.com/capacitor-community/text-to-speech
Change the language from 'en_US' to 'en' and it will work.

Unable to send ajax get requests with Meteor on Android *only*

I’ve got several Meteor apps that heavily rely on ajax get requests. At some point, one of these apps stopped being able to send ajax get requests, on recent versions of Android, only.
The same app works in the browser, on iOS, and on older versions of Android. (Or rather, on a Fire tablet.) So, I take this to mean this is not a CORS issue.
Other apps, using the same code, are not affected, on any platform.
It appears to me that Android is blocking the requests, and I don’t understand how to make this work.
Also, I've not found a device with recent version of Android where this does work, meaning it's not just my phone.
This is an example request:
$.ajax({
type: "GET",
traditional: true,
url: url,
contentType: 'application/json; charset=utf-8',
dataType: "json",
data: {},
success: function (result) {
...
},
error: function (xhr) {
var propValue;
for(var propName in xhr) {
propValue = xhr[propName]
$("#log").prepend(propName + ": " + propValue + "<br />");
}
}
});
This is the output:
statusText: error
status: 0
responseText:
error: function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){p.each(n,(function(n,r){p.isFunction®?e.unique&&l.has®||o.push®:r&&r.length&&“string”!==p.type®&&t®}))}(arguments),n&&!t&&u()),this}
success: function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){p.each(n,(function(n,r){p.isFunction®?e.unique&&l.has®||o.push®:r&&r.length&&“string”!==p.type®&&t®}))}(arguments),n&&!t&&u()),this}
complete: function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){p.each(n,(function(n,r){p.isFunction®?e.unique&&l.has®||o.push®:r&&r.length&&“string”!==p.type®&&t®}))}(arguments),n&&!t&&u()),this}
progress: function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){p.each(n,(function(n,r){p.isFunction®?e.unique&&l.has®||o.push®:r&&r.length&&“string”!==p.type®&&t®}))}(arguments),n&&!t&&u()),this}
fail: function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){p.each(n,(function(n,r){p.isFunction®?e.unique&&l.has®||o.push®:r&&r.length&&“string”!==p.type®&&t®}))}(arguments),n&&!t&&u()),this}
done: function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){p.each(n,(function(n,r){p.isFunction®?e.unique&&l.has®||o.push®:r&&r.length&&“string”!==p.type®&&t®}))}(arguments),n&&!t&&u()),this}
pipe: function(){var e=arguments; return p.Deferred((function(n){p.each(t,(function(t,o){var a=p.isFunction(e[t])&&e[t]; i[o[1]]((function(){var e=a&&a.apply(this,arguments); e&&p.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):no[0]+“With”}))})),e=null})).promise()} promise: function(e){return null!=e?p.extend(e,r):r}
then: function(){var e=arguments; return p.Deferred((function(n){p.each(t,(function(t,o){var a=p.isFunction(e[t])&&e[t]; i[o[1]]((function(){var e=a&&a.apply(this,arguments); e&&p.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):no[0]+“With”}))})),e=null})).promise()}
always: function(){return i.done(arguments).fail(arguments),this}
state: function(){return n}
abort: function(e){var t=e||w; return l&&l.abort(t),C(0,t),this}
statusCode: function(e){var t; if(e)if(b<2)for(t in e)v[t]=[v[t],e[t]]; else T.always(e[T.status]); return this}
overrideMimeType: function(e){return b||(f.mimeType=e),this}
setRequestHeader: function(e,t){var n=e.toLowerCase(); return b||(e=x[n]=x[n]||e,y[e]=t),this}
getAllResponseHeaders: function(){return 2===b?a:null}
getResponseHeader: function(e){var t; if(2===b){if(!c)for(c={}; t=Pt.exec(a); )c[t[1].toLowerCase()]=t[2]; t=c[e.toLowerCase()]}return null==t?null:t}
readyState: 0
Any insight would be greatly appreciated.
Check your SSL on backend.
Since Android 9, your api end point must :
Use HTTPS
Not be self-signed
Use public certificate authority
only

Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path error with using retrofit application and spring boot

I know this question has been asked before, but i seem to be struggling with fixing my error. I am hosting a local website from java using Spring Boot and now i have to implement an android application using retrofit. I am trying to get a simple task done of loading json objects from my website to a recycle view on android but i get the following errors:
2020-02-09 12:15:57.005 9204-9274/bootcamp.entelect.co.za.supermancomicstockapp E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
Process: bootcamp.entelect.co.za.supermancomicstockapp, PID: 9204
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:350)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)
at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:117)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:89)
at bootcamp.entelect.co.za.supermancomicstockapp.Presenter.BrowsePresenter$BrowseTaskFirst.doInBackground(BrowsePresenter.java:50)
at bootcamp.entelect.co.za.supermancomicstockapp.Presenter.BrowsePresenter$BrowseTaskFirst.doInBackground(BrowsePresenter.java:36)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
at java.lang.Thread.run(Thread.java:764) 
Here is my Browser interface:
public interface IBrowse {
void loadFirst(List<BrowseDTO> browseDTOList);
void loadNext(List<BrowseDTO> browseDTOList);
}
my Browse activity:
#Override
public void loadFirst(List<BrowseDTO> browseDTOList) {
recycleViewAdapter.addAll(browseDTOList);
if(currentPage <= TOTAL_PAGES) recycleViewAdapter.addLoadingFooter();
else isLastPage = true;
}
my browse presenter:
public static class BrowseTaskFirst extends AsyncTask<Integer,Void,List<BrowseDTO>>{
IBrowse iBrowse;
public BrowseTaskFirst(IBrowse iBrowse) {
this.iBrowse = iBrowse;
}
#Override
protected List<BrowseDTO> doInBackground(Integer... integers) {
IBrowseService iBrowseService = APIClient.createService(IBrowseService.class, Token.getInstance());
Call<List<BrowseDTO>> browseIssuesPage;
browseIssuesPage = iBrowseService.getIssuesPaginated(integers[0]);
try{
return browseIssuesPage.execute().body();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(List<BrowseDTO> browseDTOS) {
super.onPostExecute(browseDTOS);
iBrowse.loadFirst(browseDTOS);
}
}
my browse DTO:
public class BrowseDTO {
IssueDTO issuesDTO;
private List<StockDTO> stockDTOlist;
public IssueDTO getIssuesDTO() {
return issuesDTO;
}
public List<StockDTO> getStockDTOlist() {
return stockDTOlist;
}
}
and lastly my browse service/controller
public interface IBrowseService {
#GET("/Browse/{pageNumber}")
Call<List<BrowseDTO>>getIssuesPaginated(
#Path("pageNumber") int pageNumber);
}
when running the application i see the application is talking to my spring boot application because it gets the data from the website but breaks when i try to view a list of all the items
UPDATE
Here is the JSON response:
content: [
{
issueTitle: "52",
description: "When they arrive before the ruinous sweep, There shrieks are heard, there lamentations, moans, And blasphemies 'gainst the good Power in heaven.",
condition: "Average",
stockReferenceId: 49423,
availableQuantity: 0,
seriesNumber: 6,
price: 175.44,
publisher: "DC",
coverImage: "\Images\20.png"
},
{
issueTitle: "52",
description: "When they arrive before the ruinous sweep, There shrieks are heard, there lamentations, moans, And blasphemies 'gainst the good Power in heaven.",
condition: "Fine",
stockReferenceId: 24721,
availableQuantity: 1,
seriesNumber: 6,
price: 161.51,
publisher: "DC",
coverImage: "\Images\20.png"
},
{
issueTitle: "52",
description: "When they arrive before the ruinous sweep, There shrieks are heard, there lamentations, moans, And blasphemies 'gainst the good Power in heaven.",
condition: "Poor",
stockReferenceId: 74125,
availableQuantity: 0,
seriesNumber: 6,
price: 53.35,
publisher: "DC",
coverImage: "\Images\20.png"
},
{
issueTitle: "52",
description: "When they arrive before the ruinous sweep, There shrieks are heard, there lamentations, moans, And blasphemies 'gainst the good Power in heaven.",
condition: "Very Fine",
stockReferenceId: 19,
availableQuantity: 0,
seriesNumber: 6,
price: 43.06,
publisher: "DC",
coverImage: "\Images\20.png"
},
{
issueTitle: "52",
description: "Then I his alter'd hue perceiving, thus: "How may I speed, if thou yieldest to dread, Who still art wont to comfort me in doubt?"",
condition: "Average",
stockReferenceId: 49424,
availableQuantity: 0,
seriesNumber: 7,
price: 169.74,
publisher: "DC",
coverImage: "\Images\21.png"
},
{
issueTitle: "52",
description: "Then I his alter'd hue perceiving, thus: "How may I speed, if thou yieldest to dread, Who still art wont to comfort me in doubt?"",
condition: "Fine",
stockReferenceId: 24722,
availableQuantity: 0,
seriesNumber: 7,
price: 63.28,
publisher: "DC",
coverImage: "\Images\21.png"
},
The models you've posted do not conform to the json you've added in your question. When using retrofit without adding any kind of converters, the java models should match the json itself. Naming is also important.
To properly parse this object:
{
issueTitle: "52",
description: "When they arrive before the ruinous sweep, There shrieks are
heard, there lamentations, moans, And blasphemies 'gainst the
good Power in heaven.",
condition: "Poor",
stockReferenceId: 74125,
availableQuantity: 0,
seriesNumber: 6,
price: 53.35,
publisher: "DC",
coverImage: "\Images\20.png"
}
You'd have to have a java object with the same kind of structure:
class Item {
private String issueTitle;
private String description;
// and so on
}
The next step is to parse a list of these items. Since the root of your json seems to be another object, we need to create a java model that has the same structure as:
{
content: [
// ...
]
}
This can be achieved with the following model:
class BrowseDTO {
private List<Item> content;
}
And now the retrofit call should return this class:
public interface IBrowseService {
#GET("/Browse/{pageNumber}")
Call<BrowseDTO>getIssuesPaginated(
#Path("pageNumber") int pageNumber);
}
This now returns an object that matches the returned json.
The error you are getting right now says that you are telling retrofit that you expect an array - that's the List<BrowseDTO> - but instead you got an object - that's the root element in the json (content).
In this example, I've mentioned that the field names must match the ones from the json. Although this is not wrong, it's not necessarily true. Since you're using Gson, one of the easiest ways to change the name to something else is using the annotation #SerializedName which will change the name in the json and lets you use whatever field name you want, i.e:
class BrowseDTO {
#SerializedName("content")
private List<Item> items;
}
Although this is not necessarily true for all applications, in Android we always add this annotation even if it has the same name as the field, because the release builds are often obfuscated and the field name will not match the field in the json for sure.

Get data from JSONArray

I'm trying to parse data from my json with the following kotlin code:
val text = JSONObject(URL(request).readText())
val results = text.getJSONArray("results")
val name = results.getJSONObject(5).getString("name") // org.json.JSONException: Index 5 out of range [0..1)
json
{
summary: {
queryType: "NEARBY",
queryTime: 13,
numResults: 2,
offset: 0,
totalResults: 2,
fuzzyLevel: 1,
geoBias: {
lat: -37.736343,
lon: 145.152114
}
},
results: [
{
type: "POI",
id: "AU/POI/p0/77255",
score: -0.38554,
dist: 385.5365152133808,
info: "search:ta:0323405846509-AU",
poi: {
name: "La Gourmet",
However I'm getting the following error on my 3rd line:
org.json.JSONException: Index 5 out of range [0..1)
I'm not sure why I'm getting this error. I resorted to searching for name via index because .getJSONObject("poi") doesn't take a String. This is also concerning because the data may change so I would prefer to query the JSON via String.
Any idea?
results is an array, and your code tries to get the 5th element of the array. You need to get the first element, and then you can get poi by name.
val text = JSONObject(URL(request).readText())
val results = text.getJSONArray("results")
val result0 = results.getJSONObject(0)
val poi = result0.getJSONObject("poi")

LocalStorage store not persisting on Android phone when app stops using Sencha Touch 2.2 and Phonegap

This is working fine in my browser but when I install the app on my phone and use it ... it looks fine UNTIL I force it to stop and reopen the app and then all my records are gone.
Im using 2.2 and Phonegap.... any help would be VERY appreciated. Here is my store:
Ext.define('MyApp.store.Presentations', {
extend: 'Ext.data.Store',
config: {
model: 'MyApp.model.Presentations',
sorter: 'title',
grouper: function (record) {
var upperCased = record.get('title')[0].toUpperCase();
return upperCased; //First letter of the title - how we GROUP these
},
autoLoad: true,
proxy: {
type: 'localstorage',
id: 'presentations'
}
}
});
I save like this:
var newPresentation = { title: prezTitle, content: '' };
Ext.getStore('Presentations').add(newPresentation);
var newRecord = Ext.getStore('Presentations').sync();
You can try by adding the following code to the DroidGap class :
super.appView.getSettings().setAllowFileAccess(true);
super.appView.getSettings().setDatabaseEnabled(true);
super.appView.getSettings().setDatabasePath("/data/data/" + appView.getContext().getPackageName() + "/databases/");
super.appView.getSettings().setDomStorageEnabled(true);
This lines have solved the same problem that i got

Categories

Resources