我的应用使用Google的C2DM(推送通知)来通知用户有关朋友的新活动.安装应用程序后,我将设备注册到C2DM服务器并存储用户的电话号码.所以我知道用户正在使用我的应用程序,我可以向他/她发送推送通知.但是如果用户卸载我的应用程序会发生什么,有没有办法在我的应用程序中捕获它?或者唯一的方法是当我发送C2DM并且无法访问时,在我的服务器上捕获错误,然后将用户标记为非活动状态?
我很乐意在他们的朋友使用应用程序时以及他们不再使用时通知用户.
什么是这种情况的最佳解决方案?
我的应用程序中有一个TextView,我希望用户只能输入字母数字字符.如何做到这一点?谢谢!
我有一个带有两个子活动的TabHost(在两个标签中).我还在其中一个活动中实现了一个公共函数,我想从我的父母(TabHost)调用,以触发选项卡中的某些操作.
是否可以从TabHost引用活动本身来调用公共函数?
谢谢
这是我的tabhost设置:
res = getResources();
tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, home.class);
spec = tabHost.newTabSpec("home").setIndicator("Groups", res.getDrawable(R.drawable.groups)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, messages.class);
spec = tabHost.newTabSpec("messages").setIndicator("Messages", res.getDrawable(R.drawable.messages)).setContent(intent);
tabHost.addTab(spec);
Run Code Online (Sandbox Code Playgroud) 我需要从设备及其电话号码中获取所有联系人的明确列表.但是等等......我们知道某些联系人可能分配了多个号码,这完全取决于每个用户如何存储他的联系人.这是我做的:
ContentResolver cr = context.getContentResolver();
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME };
String selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '1'";
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
ArrayList<user> contacts = new ArrayList<user>();
Cursor users = a.managedQuery(uri, projection, selection, null, sortOrder);
while (users.moveToNext()) {
user u = new user();
u.PhoneId = users.getInt(users.getColumnIndex(ContactsContract.Contacts._ID));
u.Name = users.getString(users.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String homePhone = "", cellPhone = "", workPhone = "", otherPhone = "";
Cursor contactPhones = cr.query(Phone.CONTENT_URI, null, …Run Code Online (Sandbox Code Playgroud) 我的项目要求我能够在Android设备上录制音频.我使用MediaRecorder()实现了解决方案,但录制的音频质量很差.我究竟做错了什么?我必须认为这不能记录音频的唯一方法:)也许我做错了什么,我在下面包括我的代码.请指出正确的方向.
谢谢!
MediaRecorder recorder = new MediaRecorder();
File outputFile = new File(Environment.getExternalStorageDirectory(), "audio.3gp");
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(outputFile.getAbsolutePath());
recorder.prepare();
recorder.start();
// stop
recorder.stop();
recorder.reset();
recorder.release();
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我需要能够在后台发送短信,无需用户干预.我正在使用SmsManager(下面的代码)来实现这一目标.它确实发送了一条消息,但弹出窗口要求我选择一种交付方法仍然显示(即使在发送消息后).我安装了谷歌语音,因此弹出窗口.有没有办法让我在发送短信时避免显示此弹出窗口?也许我将使用不同的方法?
谢谢!
SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage(number, null, message, null, null);
Run Code Online (Sandbox Code Playgroud)
更新:所以只是为了看看会发生什么我选择了默认的传递方式是"短信"并选中表示默认使用此方法.现在,当我使用上面的代码发送消息时,它会在后台发送消息,但它也会调出空表单以发送消息给:我怎么摆脱这个?:)
android ×6
android-c2dm ×1
audio ×1
contacts ×1
detect ×1
performance ×1
recording ×1
sms ×1
textview ×1
uninstall ×1
validation ×1