我的应用程序中有一个通知,其中包含以下代码:
//Notification Start
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.n1;
CharSequence tickerText = "Call Blocker";
long when = System.currentTimeMillis(); //now
Notification notification = new Notification(icon, tickerText, when);
Intent notificationIntent = new Intent(context, Main.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
Context context = getApplicationContext();
CharSequence title = "Call Blocker";
text = "Calls will be blocked while driving";
notification.setLatestEventInfo(context, title, text, contentIntent);
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notificationManager.notify(1, notification);
}
Run Code Online (Sandbox Code Playgroud)
我的通知触发得非常好,但我的问题是,当我点击通知中心的通知时,它无法启动我的应用.
基本上,点击我的通知后没有任何反应!我应该怎么做,以便在点击我的通知后开始我的主要活动.谢谢.
我在Lyout中有一个文本视图,我想在这个textview中设置一些文本.这应该在一个不是MainActivity类的类中进行.
问题是我得到了一个空指针异常.
这是我的代码:
public class UserInformations extends Activity{
TextView emailTextView;
LocalDatabase localdatabase= new LocalDatabase(this);
public void getUserInformation()
{
emailTextView = (TextView) findViewById(R.id.EmailTextView);
String email = localdatabase.getUserEmail();
emailTextView.setText(email);
}
}
Run Code Online (Sandbox Code Playgroud)
当我在Main Activity类中执行此操作时,它可以正常工作,但它不适用于其他类.
我想将此权限添加到我的Android清单中:
Run Code Online (Sandbox Code Playgroud)<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
但是在我将此权限粘贴到我的清单后,它会测试红色下划线并说:
权限仅授予系统应用程序
我能做什么?
我想在此图片中创建一个类似红色边框通知的通知:

我知道如何在此图像中创建普通通知,例如蓝色边框通知,但我想在其附近显示一个图标和大约3行信息.我怎样才能做到这一点?任何建议将不胜感激.
我正在用swift开发一个iPhone应用程序.我正在使用Alamofire框架来处理http请求.我Alamofire.request像这样用于POST,GET等:
Alamofire.request(.POST, myURL , parameters: ["a": "1", "b" : "2" ])
.response { (request, response, data, error) in
}
Run Code Online (Sandbox Code Playgroud)
我Alamofire.upload用来将图像上传到服务器:
Alamofire.upload(.POST, uploadURL , fileURL)
Run Code Online (Sandbox Code Playgroud)
两者都很完美,但现在我想上传一个图像并发送一些参数,我的内容类型应该是multipart/form-data并且Alamofire.upload不接受参数.
有两个问题,更SO关于这一问题迅速,其中第一个没有使用Alamofire(真的,为什么不呢?),并在第二个,mattt(Alamofire开发)引用使用的编码参数.
我检查了他的例子,但仍然无法弄清楚如何做到这一点.
任何人都可以帮我解决这个问题吗?
谢谢!:)
我的代码中有一个首选项活动.我想在用户更改ListPreferences中的单选按钮时显示祝酒词.我使用了这段代码,但它不起作用.:(
public class PrefsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
}
public void onSharedPreferenceChanged(SharedPreferences arg0, String key) {
ListPreference listPreference = (ListPreference) findPreference(key);
listPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// TODO Auto-generated method stub
Toast.makeText(PrefsActivity.this, "second", Toast.LENGTH_LONG).show();
return false;
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是什么?
过了两天,我每45秒不断收到一个错误对话框,标题为:
发生了多个问题
在下面说:
java.lang.ClassCastException
在详细信息中,有重复的行显示:
org.eclipse.core.internal.dtree.NoDataDeltaNode无法转换为org.eclipse.core.internal.dtree.DataTreeNode
这是一张照片:

我按OK,然后继续编码,我的代码在模拟器和手机上都可以正常工作,但是每分钟看到此对话框真是令人讨厌,甚至不到一分钟!
我的代码中有一个拨号框,当我点击Main活动中的一个按钮弹出时,这个稀释框是这样的:

我想将字符串数据从"输入NUmber"和"输入名称"测试框放到主要活动中的viewText,我不知道如何传输这个值.弹出对话框的代码部分是这样的:
btnstart.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// Auto-generated method stub
final Dialog dialog = new Dialog(Main0.this);
dialog.setContentView(R.layout.number);
dialog.setTitle("Save New Number");
dialog.setCancelable(true);
dialog.show();
}
});
Run Code Online (Sandbox Code Playgroud) 我已经UINavigationController在我的应用程序中,我希望有权UIBarButtonItem在我的应用程序中显示的所有导航栏中显示.这个按钮会加载菜单,所以我不想手动在每个导航栏中添加这个按钮,因为该功能正在加载菜单,我不想复制/过去此按钮的操作.
有没有什么办法来处理这ViewController.h和.m?
所以按钮充当通用栏按钮项?
uinavigationbar uinavigationcontroller uibarbuttonitem uinavigationitem ios
我已经成功地为Swift编写了一个适用于iOS的自定义键盘,并且可以完美地在所有iOS模拟器(iPhone 5s,iPhone 6,iPhone 6Plus)上加载。但是当我尝试在物理设备上测试键盘时,键盘将无法加载。:|
我正在使用Xcode 6.0.1,并且我的iPhone运行的是iOS 8(非Beta版),并且在设置的“键盘”部分中添加了键盘。
键盘完美地加载到模拟器上,而不是实际设备上,这很奇怪。
有什么我想念的吗?
我正在尝试编写应用程序以从图库中获取图像,然后在其上执行一些效果,并在显示图像后,我想将其保存为SdCard中的JPG.任何人都可以告诉我如何在SD卡上保存图像,我应该在哪里放保存代码?这是我想要保存的地方,点击button2后:
public void onClick(View arg0) {
Bitmap yourimage;
yourimage=toGrayscale(yourSelectedImage);
ImageButton effected=(ImageButton)findViewById(R.id.imageButton2);
int width = 150;
int height =150;
Bitmap resizedbitmap=Bitmap.createScaledBitmap(yourimage, width, height, true);
effected.setImageBitmap(resizedbitmap);
}
Run Code Online (Sandbox Code Playgroud)
我的意思是在设置图像为resizedbitmap后,我想将其保存在SD卡中
我有一个服务,"启动服务"可以通过2个活动调用,我想在服务启动时更改图像视图,但是当我尝试"findViewById"时,我收到了这个错误.
The method findViewById(int) is undefined for the type Main
Run Code Online (Sandbox Code Playgroud)
我该怎么办 ?
我有PrefActivity,当用户更改列表首选项中的任何按钮时,我使用OnChange Listener进行祝酒.但现在我有2个问题:1,第一次更改用户未显示的选项吐司2之后,用户永远改变prefrences,列表的值时不会更新,并且始终设置第二个值.
这是我的代码:
public class PrefsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener{
private ListPreference myPreference;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
}
public void onSharedPreferenceChanged(SharedPreferences arg0, String key) {
ListPreference lp = (ListPreference) findPreference("blocktype");
lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// TODO Auto-generated method stub
Toast.makeText(PrefsActivity.this, "second", Toast.LENGTH_LONG).show();
return false;
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
什么是
android ×10
ios ×2
swift ×2
alamofire ×1
android-view ×1
bitmap ×1
dialog ×1
eclipse ×1
findviewbyid ×1
image ×1
iphone ×1
java ×1
jpeg ×1
keyboard ×1
permissions ×1
preference ×1
preferences ×1
save ×1
service ×1
simulator ×1
toast ×1
upload ×1
xcode ×1