我正在尝试制作一个新的应用程序,我想获得股票更新、货币兑换更新等。你能推荐一些免费的 API 来获取这些更新吗?我已经尝试过:
1)谷歌财经API。不使用的原因:已弃用并即将关闭,这将使我的应用程序过时。
2)雅虎财经API。不使用的原因:没有适当的文档。原因是雅虎实际上没有财务 API。似乎有些人对他们用来提取财务数据的 API 进行了逆向工程,但他们违反了雅虎的服务条款。我不想那样做。(阅读http://developer.yahoo.com/forum/General-Discussion-at-YDN/Using-Yahoo-Finance-API-Not-RSS-/1250246255000-0b82f8f0-7f48-3af2-8fe2-e73a138cbfaa)
如果提供指向某些资源或代码的链接,那就太好了。我在这里先向您的帮助表示感谢。
我有一个奇怪的问题。从微调器中选择一项时,我需要做一些事情。
这是我的代码:
language = (Spinner) findViewById(R.id.current_language_text);
ArrayAdapter adapter = new ArrayAdapter(this,
com.Orange.R.layout.my_spinner_textview, languages);
adapter.setDropDownViewResource(com.Orange.R.layout.multiline_spinner_dropdown_item);
language.setAdapter(adapter);
language.setSelection(Integer.valueOf(language_id) - 1);
language.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
System.out.println("position "+position);
Toast.makeText(Settings.this, "Hello Toast",Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
// your code here
}
});
Run Code Online (Sandbox Code Playgroud)
问题是onItemSelectedListener没有被调用。我放进去了System.out.println,onItemSelected()但是我在LogCat中找不到。我尝试使用Toast,但结果相同,但没有出现。每次我从微调器中选择一个项目时,在LogCat中都会收到以下警告:
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2b1dabd0
Run Code Online (Sandbox Code Playgroud)
知道为什么不调用onItemSelectedListener吗?
我正在尝试创建一个相册并使用imgurpython将图像上传到其中。但是,我无法将图像附加到相册中。它给了我以下错误:(403) The album you're requesting does not belong to your account。以下是我的代码:
client = ImgurClient(client_id, client_secret)
def CreateAlbumAndUploadImages(albumName,albumDescription,images):
fields = {}
fields['title'] = albumName
fields['description'] = albumDescription
fields['privacy'] = 'public'
x = client.create_album(fields)
print(x)
y = client.album_add_images(x['id'],images) #error here
print(y)
return x
def UploadPhoto(images):
config = {
'name': 'some image name here',
'title': 'some title here',
'description': 'some description here'}
image = client.upload_from_path(image_path, config=config, anon=False)
print("Done")
print(image)
return image
def main():
#x = CreateAlbum('Album 101','Album 101 desciption')
id …Run Code Online (Sandbox Code Playgroud) 我想与我的应用程序分享一些东西.一旦共享(例如 - 发送消息),我希望我的应用程序再次处于活动状态,并且发送应用程序将消失.使用下面的代码,我希望onActivityResult被调用,但它永远不会被调用.
发送电子邮件后,我的应用程序再次出现,但在发送SMS('Messaging')后,消息传递应用程序仍然存在.(onActivityResult从未被称为)
谢谢 :-)
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "This is a test";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "You have to see this!");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivityForResult(Intent.createChooser(sharingIntent, "Share via"),1);
getFragmentManager().popBackStack();
Run Code Online (Sandbox Code Playgroud) 进度条不会更新.但是,它在完成任务时结束.
int totalSms = 12;
int currentSms = 0;
public class ProgressTask extends AsyncTask<String, Integer, Boolean> {
/** progress dialog to show user that the backup is processing. */
private ProgressDialog dialog;
public ProgressTask(ScanInboxActivity activity) {
dialog = new ProgressDialog(activity);
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setMax(totalSms);
}
protected void onPreExecute() {
dialog.setMessage("Scan start");
dialog.show();
}
@Override
protected void onProgressUpdate(Integer... values) {
Log.d(TAG, "in onProgressUpdate: " + values[0]); // shows actuall count in the log
dialog.setProgress(values[0]); // does not update
//tried even this, …Run Code Online (Sandbox Code Playgroud) 这是我想要做的:我有一个小部件,我想根据用户选择的颜色设置其背景。它必须是一个渐变。背景是通过设置linearLayout的背景来设置的。为了测试,我做了一个虚拟背景:
remoteViews.setInt(R.id.layout, "setBackgroundResource", R.drawable.widget_background);
Run Code Online (Sandbox Code Playgroud)
我见过这个问题:从 RemoteViews 调用 setImageDrawable但我无法理解如何实现。我什至找不到setXYZ()那里提到的。这是我迄今为止尝试过的:
尝试将 ImageView 作为背景(在 LinearLayout 之前)。它没有为小部件提供适当的边距。由于小部件文本是动态的,有时它会从 imageView 中消失,这不是我想要的
制作一个 bg.xml,其中我有:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)现在我完全困惑和卡住了。有人可以尽快帮助(可能更多的代码和更少的链接)吗?另外,请不要像已经问过的那样关闭这个问题。
甚至没有调用Log.d.找不到错误.我看过Android - 短信广播接收器,Android - 收听传入短信.我一直在寻找解决方案,持续24小时左右.请看看并告诉我哪里错了.
没有异常被抛出.SmsListener在我的包文件夹中,放置所有其他活动.
更新添加android:enabled="true"到接收器.然后也没工作.
我有我的清单:
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<receiver android:name=".SmsListener" android:exported="false">
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
SmsListener.Java代码:
public class SmsListener extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(MainActivity.TAG,
"in Receiver. intent.getAction():" + intent.getAction());
if (intent.getAction()
.equals("android.provider.Telephony.SMS_RECEIVED")) {
Bundle bundle = intent.getExtras(); // ---get the SMS message passed
// in---
SmsMessage[] msgs = null;
String msg_from;
if …Run Code Online (Sandbox Code Playgroud) 我有一个正则表达式来识别一些命名组。有少数情况下有多个具有不同模式的组。问题是将所有命名组放入相应的列表中。限制是我不能有多个正则表达式,并且不能多次调用执行正则表达式。我尝试过以下代码,但它总是返回第二种模式:
Regex reg = new Regex(@"(?<n1>pattern_n1_1) (?<n2>pattern_n2_1) (?<n1>pattern_n1_2) (?<n2>pattern_n1_2)", RegexOptions.IgnoreCase);
String str = "pattern_n1_1 pattern_n2_1 pattern_n1_2 pattern_n1_2";
List<String> matchedText = new List<string>();
List<String> string_n1 = new List<string>();
List<String> string_n2 = new List<string>();
MatchCollection mc = reg.Matches(str);
if (mc != null)
{
foreach (Match m in mc)
{
matchedText.Add(m.Value.Trim());
string_n1.Add(m.Groups["n1"].Value);
string_n2.Add(m.Groups["n2"].Value);
}
}
Run Code Online (Sandbox Code Playgroud)
这里的列表string_n1和string_n2各有一个元素。string_n1具有“pattern_n1_2”和string_n2“pattern_n2_2”。但是,我要求“pattern_n1_1”和“pattern_n1_2”都在string_n1并且“pattern_n2_1”和“pattern_n2_2”都在string_n2