我正试图让我的应用程序从EditText调用一个数字,但我得到:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.DIAL dat=Ring Tel nr. 123456789 }
Run Code Online (Sandbox Code Playgroud)
我已经搜索了一段时间以获得答案,但大多数答案都是权限并向Manifest添加活动.我做过两件事,如果我做错了.我在手机上运行它,而不是模拟器.我曾尝试使用和不使用intent-filters.以下是代码:清单:<uses-permission android:maxSdkVersion="19" android:name="android.permission.CALL_PHONE"/>
<activity
android:name="nu.sluggo.testapp.annons.Activity2">
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
拨打电话的按钮(从SharedPrefs获取电话号码到下面的a1 :)
knapp_ring.setOnClickListener(new View.OnClickListener() {
Intent call = new Intent(Intent.ACTION_DIAL);
@Override
public void onClick(View v){
call.setData(Uri.parse("Telnr:" + a1));
startActivity(call);
}
});
Run Code Online (Sandbox Code Playgroud) android phone-call phone-number android-intent android-permissions
我是javascript的新手,我正在尝试通过JSLint进行验证.我应该在哪里使用"use strict"在全球范围内使用它并验证?
这给了我错误"在语句位置使用严格'的意外表达式.":
"use strict";
console.log('doing js in head-section');
function helloWorld() {
console.log('called function helloWorld()');
alert('Hello World from a JS function showing an alert!');
}
function helloMyNumber() {
console.log('called function helloMyNumber()');
var max = 42;
var yourLuckyNumber = prompt('Enter your lucky number (between 1 and '+ max +')');
var myLuckyNumber = Math.floor(Math.random()*(max+1));
var paragraph = document.getElementById('luckynumber');
paragraph.innerHTML = paragraph.innerHTML + ' Your lucky number is: ' + yourLuckyNumber + '. Mine is: ' + myLuckyNumber + '. They ' + …
Run Code Online (Sandbox Code Playgroud) 我在"textTo.getText().toString();"上遇到nullPointerException.下面.我不明白为什么.我已经尝试将EditText的findViewById放在onClick中,但没有区别.
Maila.Java:
public class Maila extends Fragment implements OnClickListener{
public static Maila newInstance() {
Maila f = new Maila();
System.out.println("Initialiserad");
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.contact_form, container, false);
return v;
}
Button buttonSend;
EditText textTo;
EditText textSubject;
EditText textMessage;
EditText textName;
EditText textTel;
EditText textFrom;
@Override
public void onViewCreated (View v, Bundle SavedInstanceState){
buttonSend = (Button) getView().findViewById(R.id.mailKnapp);
textTo = (EditText) getView().findViewById(R.string.mailAdress);
textSubject = (EditText) getView().findViewById(R.id.editTextMeddelandeTitel);
textName = (EditText) getView().findViewById(R.id.editTextNamn); …
Run Code Online (Sandbox Code Playgroud)