Obsolete
Status Update
Comments
rh...@gmail.com <rh...@gmail.com> #2
Supporting RingtonePreference would have required porting over some awkward plumbing to route the activity result back to the preference object, and it made more sense to just leave it in the hands of the app developer to handle this by overriding onPreferenceTreeClick and then launching the ringtone activity themselves (see RingtoneManager.ACTION_RINGTONE_PICKER).
en...@google.com <en...@google.com>
je...@gmail.com <je...@gmail.com> #3
That would be nice to point out in the API docs. Here's how I implemented the workaround described:
In you preferences XML resource, change RingtonePreference to Preference. Then, in your implementation of PreferenceFragment, add:
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey().equals(KEY_RINGTONE_PREFERENCE)) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, Settings.System.DEFAULT_NOTIFICATION_URI);
String existingValue = getRingtonePreferenceValue(); // TODO
if (existingValue != null) {
if (existingValue.length() == 0) {
// Select "Silent"
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
} else {
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(existingValue));
}
} else {
// No ringtone has been selected, set to the default
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Settings.System.DEFAULT_NOTIFICATION_URI);
}
startActivityForResult(intent, REQUEST_CODE_ALERT_RINGTONE);
return true;
} else {
return super.onPreferenceTreeClick(preference);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_ALERT_RINGTONE && data != null) {
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
if (ringtone != null) {
setRingtonPreferenceValue(ringtone.toString()); // TODO
} else {
// "Silent" was selected
setRingtonPreferenceValue(""); // TODO
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
In you preferences XML resource, change RingtonePreference to Preference. Then, in your implementation of PreferenceFragment, add:
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey().equals(KEY_RINGTONE_PREFERENCE)) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, Settings.System.DEFAULT_NOTIFICATION_URI);
String existingValue = getRingtonePreferenceValue(); // TODO
if (existingValue != null) {
if (existingValue.length() == 0) {
// Select "Silent"
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
} else {
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(existingValue));
}
} else {
// No ringtone has been selected, set to the default
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Settings.System.DEFAULT_NOTIFICATION_URI);
}
startActivityForResult(intent, REQUEST_CODE_ALERT_RINGTONE);
return true;
} else {
return super.onPreferenceTreeClick(preference);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_ALERT_RINGTONE && data != null) {
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
if (ringtone != null) {
setRingtonPreferenceValue(ringtone.toString()); // TODO
} else {
// "Silent" was selected
setRingtonPreferenceValue(""); // TODO
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
ma...@gmail.com <ma...@gmail.com> #4
It would be nice if this got fixed. Especially considering C++11 is almost four years old now.
da...@google.com <da...@google.com> #5
It's actually because of the _GLIBCXX_USE_C99 define, which (at least in master), looks to be disbled because complex.h isn't fully compliant. Thanks to the wonderful autoconf setup, that prevents you from using string functions...
From our build log:
checking for ISO C99 support in <math.h>... yes
checking tgmath.h usability... no
checking tgmath.h presence... no
checking for tgmath.h... no
checking complex.h usability... yes
checking complex.h presence... yes
checking for complex.h... yes
checking for ISO C99 support in <complex.h>... no
checking for ISO C99 support in <stdio.h>... yes
checking for ISO C99 support in <stdlib.h>... yes
checking for ISO C99 support in <wchar.h>... yes
checking for fully enabled ISO C99 support... no
autoconf checks for that support using this:
#include <complex.h>
typedef __complex__ float float_type;
typedef __complex__ double double_type;
typedef __complex__ long double ld_type;
volatile float_type tmpf;
volatile double_type tmpd;
volatile ld_type tmpld;
volatile float f;
volatile double d;
volatile long double ld;
int
main ()
{
f = cabsf(tmpf);
f = cargf(tmpf);
tmpf = ccosf(tmpf);
tmpf = ccoshf(tmpf);
tmpf = cexpf(tmpf);
tmpf = clogf(tmpf);
tmpf = csinf(tmpf);
tmpf = csinhf(tmpf);
tmpf = csqrtf(tmpf);
tmpf = ctanf(tmpf);
tmpf = ctanhf(tmpf);
tmpf = cpowf(tmpf, tmpf);
tmpf = cprojf(tmpf);
d = cabs(tmpd);
d = carg(tmpd);
tmpd = ccos(tmpd);
tmpd = ccosh(tmpd);
tmpd = cexp(tmpd);
tmpd = clog(tmpd);
tmpd = csin(tmpd);
tmpd = csinh(tmpd);
tmpd = csqrt(tmpd);
tmpd = ctan(tmpd);
tmpd = ctanh(tmpd);
tmpd = cpow(tmpd, tmpd);
tmpd = cproj(tmpd);
ld = cabsl(tmpld);
ld = cargl(tmpld);
tmpld = ccosl(tmpld);
tmpld = ccoshl(tmpld);
tmpld = cexpl(tmpld);
tmpld = clogl(tmpld);
tmpld = csinl(tmpld);
tmpld = csinhl(tmpld);
tmpld = csqrtl(tmpld);
tmpld = ctanl(tmpld);
tmpld = ctanhl(tmpld);
tmpld = cpowl(tmpld, tmpld);
tmpld = cprojl(tmpld);
;
return 0;
}
We are (bionic in the platform too, not just the NDK) in fact missing a bunch of the complex math functions. I'll file a bug about getting these added to bionic.
From our build log:
checking for ISO C99 support in <math.h>... yes
checking tgmath.h usability... no
checking tgmath.h presence... no
checking for tgmath.h... no
checking complex.h usability... yes
checking complex.h presence... yes
checking for complex.h... yes
checking for ISO C99 support in <complex.h>... no
checking for ISO C99 support in <stdio.h>... yes
checking for ISO C99 support in <stdlib.h>... yes
checking for ISO C99 support in <wchar.h>... yes
checking for fully enabled ISO C99 support... no
autoconf checks for that support using this:
#include <complex.h>
typedef __complex__ float float_type;
typedef __complex__ double double_type;
typedef __complex__ long double ld_type;
volatile float_type tmpf;
volatile double_type tmpd;
volatile ld_type tmpld;
volatile float f;
volatile double d;
volatile long double ld;
int
main ()
{
f = cabsf(tmpf);
f = cargf(tmpf);
tmpf = ccosf(tmpf);
tmpf = ccoshf(tmpf);
tmpf = cexpf(tmpf);
tmpf = clogf(tmpf);
tmpf = csinf(tmpf);
tmpf = csinhf(tmpf);
tmpf = csqrtf(tmpf);
tmpf = ctanf(tmpf);
tmpf = ctanhf(tmpf);
tmpf = cpowf(tmpf, tmpf);
tmpf = cprojf(tmpf);
d = cabs(tmpd);
d = carg(tmpd);
tmpd = ccos(tmpd);
tmpd = ccosh(tmpd);
tmpd = cexp(tmpd);
tmpd = clog(tmpd);
tmpd = csin(tmpd);
tmpd = csinh(tmpd);
tmpd = csqrt(tmpd);
tmpd = ctan(tmpd);
tmpd = ctanh(tmpd);
tmpd = cpow(tmpd, tmpd);
tmpd = cproj(tmpd);
ld = cabsl(tmpld);
ld = cargl(tmpld);
tmpld = ccosl(tmpld);
tmpld = ccoshl(tmpld);
tmpld = cexpl(tmpld);
tmpld = clogl(tmpld);
tmpld = csinl(tmpld);
tmpld = csinhl(tmpld);
tmpld = csqrtl(tmpld);
tmpld = ctanl(tmpld);
tmpld = ctanhl(tmpld);
tmpld = cpowl(tmpld, tmpld);
tmpld = cprojl(tmpld);
;
return 0;
}
We are (bionic in the platform too, not just the NDK) in fact missing a bunch of the complex math functions. I'll file a bug about getting these added to bionic.
Description
Here are my actual Application.mk settings:
APP_MODULES := TestLib
APP_CPPFLAGS := -std=c++11
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DDEBUG
APP_USE_CPP0X := true
APP_ABI := armeabi-v7a
APP_PLATFORM:=android-21
APP_STL := gnustl_static
APP_GNUSTL_CPP_FEATURES := rtti exceptions
NDK_TOOLCHAIN_VERSION=4.9
The visibility appears to be guarded inside "basic_string.h", quite possibly due to "_GLIBCXX_HAVE_BROKEN_VSWPRINTF".
I also testet static STLPort STL implementation and receive the same "std::to_string" not found error.