我试图通过广播将字符串从服务发送到我的主要活动.我在几个论坛上看到有两种方法可以使用广播.一个是在表演中注册活动,第二个方式是在活动中进行本地化.我想知道如何使用第二种方式.我试过这样做但不幸的是我没有成功.
请告诉我我做错了什么.
服务代码
public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
String typemessage = data.getString("typemessage"); // typeMessage = 0 or 1 = lock or unlock
String datamessage = data.getString("datamessage"); // dataMessage = time and message that says lock or unlock
Log.d(TAG, "TypeMessage: " + typemessage);
Log.d(TAG,"DataMesaage:"+ datamessage);
Intent in = new Intent();
in.putExtra("TYPE",typemessage);
in.setAction("NOW");
sendBroadcast(in);
Run Code Online (Sandbox Code Playgroud)
主要活动代码
public class MainActivity extends Activity implements SensorEventListener, Listen …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Unity整合到iOS应用程序中.我已按照本教程http://www.agnosticdev.com/blog-entry/swift/integrating-unity-and-vuforia-ios-swift-project
现在,在我启动应用程序时进行集成后,它会崩溃并在控制台上显示此错误: was compiled with optimization - stepping may behave oddly; variables may not be available.
我试过谷歌搜索这个链接:
并没有改变.
我已经改变了项目和pod的优化级别.我还将此行添加到pod文件中:( project 'MyProject', 'Debug - local'=>:debug, 'Debug - staging'=>:debug, 'Debug - PRODUCTION'=>:debug在目标'projectname'之前)
我也统一取消选中Strip Engine Code.
我该怎么做才能克服这个错误?任何帮助将不胜感激,谢谢.
我用了 :
NotificationCenter.default.addObserver(self, selector:#selector(keyboardWillShow), name: .UIKeyboardWillShow, object: nil)
@objc func keyboardWillShow(notification: NSNotification) {
if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
let keyboardHeight : Int = Int(keyboardSize.height)
print("keyboardHeight",keyboardHeight)
KeyboardHeightVar = keyboardHeight
}
}
Run Code Online (Sandbox Code Playgroud)
进行更改以获取键盘的高度,但高度不包括建议栏。如何获得键盘高度加上建议栏高度的值?
我需要获得最后10个元素或10分钟和array.count.在Objective-C中,我这样做了:
Objective-C代码:
NSRange endRange = NSMakeRange(sortedArray.count >= 10 ? sortedArray.count - 10 : 0, MIN(sortedArray.count, 10));
NSArray *lastElements= [sortedArray subarrayWithRange:endRange];
Run Code Online (Sandbox Code Playgroud)
在Swift中我做到了:
let endRange = NSMakeRange(values.count >= 10 ? values.count - 10 : 0, min(values.count , 10) )
Run Code Online (Sandbox Code Playgroud)
但是不知道如何在swift中使用这个范围来获取数组.任何帮助,将不胜感激.谢谢.
我是 node.js 的新手,所以我陷入了这一点。我尝试从这些网站Code Mentor和Github学习它
到目前为止我已经这样做了:
var mysql = require('mysql');
var app = express();
// Database operations
var connection = mysql.createConnection({
host : 'localhost',
port : '8888',
user : 'sharad',
password : 'teks',
dbName : 'FirstDataBase'
});
connection.connect(function (error) {
if (error){
console.error('error connecting :' + error.stack);
return;
}
console.log('Connected as id :'+ connection.threadId);
});
app.get("/",function(request,response){
console.log(' saving');
var post = {from:'me', to:'you', msg:'hi'};
connection.query('INSERT INTO FirstDataBase SET ?', post, function(err, result) {
if (err) throw err;
}); …Run Code Online (Sandbox Code Playgroud) 我尝试firebase从版本4.2.0 升级到版本5.4.1.我在构建IOS时遇到了这个错误:
对于建筑x86_64的未定义符号:
"_OBJC_CLASS _ $ _ GULAppEnvironmentUtil",从引用:在FirebaseCoreDiagnostics(FIRDiagnostics_b8d2083bbf595e32a15f4c92bf56379b.o)objc级-REF "_OBJC_CLASS _ $ _ GULNetwork",从引用:在FirebaseCoreDiagnostics(FIRClearcutLogger_39f37e7cc81dbdcb1b22721b95a40297.o)LD objc级-REF:在架构x86_64 clang中找不到符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)
任何想法如何解决?谢谢!
我有一个 tableview 单元格,其中添加了 collectionview 单元格(用于水平滚动)。
现在我想在按下水平集合视图的任何单元格时推送到其他导航控制器。怎么做 ?或者我如何定义单元格按压的委托方法。
代码 :
ViewController.swift :
class ViewController: UIViewController {
var categories = ["Action", "Drama", "Science Fiction", "Kids", "Horror"]
}
extension ViewController : UITableViewDelegate { }
extension ViewController : UITableViewDataSource {
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return categories[section]
}
func numberOfSections(in tableView: UITableView) -> Int {
return categories.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> …Run Code Online (Sandbox Code Playgroud) 如何在 Alamofire 中发布这种形式的参数?
[{"view_id":"108","Class_id":"VIII"}]
Run Code Online (Sandbox Code Playgroud)
通常Alamofire接受 [String:Any]参数,当我在Alamofire请求中输入此参数时,它会引发错误:
"extra call method"
Run Code Online (Sandbox Code Playgroud) 我有一个基本问题.在我的表视图中获取数据时objective C.有三个差异图像,标题,描述.所以我的问题是我是否应该NSArrays为它们制作3个差异,或者只是制作一个三个变量的类并制作一个对象数组以提高效率.
拿3个阵列:
NSArray *image = [NSArray withObjects : @"one.jpg",@"two.jpg",nil];
NSArray *title = [NSArray withObjects : @"one",@"two",nil];
NSArray *description = [NSArray withObjects : @"number one",@"number two",nil];
or
User *dataOne = [User new]
dataOne.image= @"one.jpg";
dataOne.title = @"one";
dataOne.description =@"Number One";
User *dataTwo = [User new]
dataTwo.image= @"one.jpg";
dataTwo.title = @"one";
dataTwo.description =@"Number One";
NSArray *data = [NSArray dataOne,dataTwo, nil];
Run Code Online (Sandbox Code Playgroud)
哪种方法更好?请说清楚.谢谢
我使方法"showResult"静态但我有问题:
"Toast.makeText(`getActivity()`.getApplication(), result2 + "\n" + "Total Amount:=" + totalAmount2 + "€", Toast.LENGTH_LONG).show();"
Run Code Online (Sandbox Code Playgroud)
怎么解决我的问题?我将分享我的代码.
感谢每一个人!
这是我的第一个类Fragment.java
public class MyListFragment extends Fragment implements
android.widget.CompoundButton.OnCheckedChangeListener {
ListView lv;
ArrayList<Planet> planetList;
static PlanetAdapter plAdapter;
BirraAdapter biAdapter;
PlanetAdapter.PlanetHolder holder;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_list2, container, false);
Button mButton = (Button) rootView.findViewById(R.id.button);
mButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showResult(v);
}
});
//return inflater.inflate(R.layout.fragment_list2, container, false);
return …Run Code Online (Sandbox Code Playgroud) ios ×7
swift ×5
android ×2
arrays ×2
alamofire ×1
firebase ×1
iphone ×1
keyboard ×1
mysql ×1
node.js ×1
objective-c ×1
optimization ×1
uitableview ×1