我正在为Android实现谷歌地图.我创建了一个测试应用程序,并在该应用程序中插入了所有权限等,应用程序运行完美.
但是当我尝试将相同的代码复制到我的真实应用程序时,它会在android活动上显示我的空白屏幕.虽然我已经更新了包中的名称google api console
.
这是我的Test Project Manifest看起来像:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapstutorial"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.mapstutorial.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.mapstutorial.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my api key"/>
<activity
android:name="com.example.mapstutorial.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
这是我的真实项目清单的样子:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shop.shoppinglist"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<permission android:name="com.shop.addtask.permission.MAPS_RECEIVE" …
Run Code Online (Sandbox Code Playgroud) 我有一个MultiAutoCompleteTextView
自定义控件,当用户按空格键时,我将在其中创建芯片文本。
我不希望用户在文本框为空时最初输入空格,因此我放置了一个inputFilter
以防止用户最初输入空格。
这是过滤器代码:
private void RestrictUselessSpaces(){
InputFilter filter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (Character.isWhitespace(source.charAt(i))) {
if(!getText().toString().trim().equals(""))
{
return " ";
}
else
{
return "";
}
}
}
return null;
}
};
setFilters(new InputFilter[]{filter});
}
Run Code Online (Sandbox Code Playgroud)
不知怎的,当我评论RestrictUselessSpaces
功能。效果很好。但是当这个函数运行时。如果我尝试在字符后输入空格。它给了我indexoutofboundexception
错误。这是我收到错误的代码。
public void setChips(String s){
if(s.contains(" ") && !s.trim().equals("")) // check space …
Run Code Online (Sandbox Code Playgroud) afterEach(()=> {Fixture.destroy();});我目前正在尝试为基于ngrx的angular 7应用程序编写测试。问题是我的测试失败并显示错误Uncaught TypeError: Cannot read property 'xxxx' of undefined thrown
。这是我的测试文件的样子。
Explore-products.component.spec.ts
import { async, ComponentFixture, TestBed } from "@angular/core/testing";
import { ExploreProductsComponent } from "./explore-products.component";
import { provideMockStore, MockStore } from "@ngrx/store/testing";
import { IAppState } from "src/app/store/state/app.state";
import { Store, StoreModule } from "@ngrx/store";
import { appReducers } from "src/app/store/reducers/app.reducer";
describe("ExploreProductsComponent", () => {
let component: ExploreProductsComponent;
let fixture: ComponentFixture<ExploreProductsComponent>;
let store: MockStore<IAppState>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ExploreProductsComponent],
providers: [provideMockStore()],
imports: [StoreModule.forRoot(appReducers)]
});
store = …
Run Code Online (Sandbox Code Playgroud) 我的角度应用程序中有一个GeoLocationService
这样的。
import { Injectable } from "@angular/core";
import { Observable } from "rxjs/Observable";
@Injectable()
export class GeoLocationService {
coordinates: any;
constructor() {}
public getPosition(): Observable<Position> {
return Observable.create(observer => {
navigator.geolocation.watchPosition((pos: Position) => {
observer.next(pos);
}),
() => {
console.log("Position is not available");
},
{
enableHighAccuracy: true
};
});
}
}
Run Code Online (Sandbox Code Playgroud)
我想对该服务进行单元测试,以确保该getPosition()
函数返回一个有效的Observable
. 这是我的测试的样子。
import { TestBed, fakeAsync } from "@angular/core/testing";
import { GeoLocationService } from "./geo-location.service";
import { take } from "rxjs/operators";
describe("GeoLocationService", () …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为ActivatedRoute
. 这是我的测试的样子。
it("should check if subscribes are called in init", () => {
const subRouteSpy = spyOn(activatedRouteStub.paramMap, "subscribe");
component.ngOnInit();
expect(subRouteSpy).toHaveBeenCalled();
});
Run Code Online (Sandbox Code Playgroud)
我的TestBed config
:
const activatedRouteStub = {
paramMap: {
subscribe() {
return of();
}
}
};
TestBed.configureTestingModule({
declarations: [HomeFilterDrawerComponent],
providers: [
{ provide: ActivatedRoute, useValue: activatedRouteStub }
],
imports: [
FormsModule,
StoreModule.forRoot(appReducers),
HttpClientTestingModule,
RouterTestingModule
]
}).compileComponents();
Run Code Online (Sandbox Code Playgroud)
测试一直失败让我Expected spy subscribe to have been called.
不确定我在这里做错了什么。
ngOnInit
组件内部的代码。
this.route.paramMap.subscribe(params => {
if (params["params"].slug !== undefined) {
} …
Run Code Online (Sandbox Code Playgroud) 我有一个Profile.php
包含Profile_Control.php
和profile_control
包含的文件Profile_Model.php
.在这里,每件事情都很好.
我有另一个脚本命名,Upload.php
从哪个数据上传.这个Upload.php还包括Profile_Control.php
并且如你所知Profile_Control
包含Profile_Model.php
.现在我不知道它为什么会出现这样的错误.当Profile.php加载它工作正常但是当我上传数据时它说
Warning: include(../Model/Profile_Model.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\php\gagster\Control\Profile_Control.php on line 4
Run Code Online (Sandbox Code Playgroud)
在Upload.php中:
include_once("../../Control/Profile_Control.php");
Run Code Online (Sandbox Code Playgroud)
在Profile.php中:
include_once("../Control/Profile_Control.php");
Run Code Online (Sandbox Code Playgroud)
在Profile_Control.php中:
include_once("../Model/Profile_Model.php");
Run Code Online (Sandbox Code Playgroud)
文件结构:
+-Control/
| |
| +---- Profile_Control.php
|
+-Model/
| |
| +---- Profile_Model.php
|
+-Other/
|
+-- Upload/
|
+---- Upload.php
Run Code Online (Sandbox Code Playgroud) 我正在尝试将httpRequest发送到codeigniter控制器函数.我正在使用REST控制台来测试该功能.我想发送3 POST
变量.
这是处理请求的代码
public function NewUser()
{
if($this->input->post())
{
$FID = $this->input->post('UserID');
$UserName = $this->input->post('UserName');
$Email = $this->input->post('Email');
echo "working";
echo $FID;
echo $UserName;
}
else
{
echo "not working";
}
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用.它总是输出not working
.当我改变一切时,get
一切都开始正常.
可能是什么问题 ?在此过程中,发布请求无法正常工作codeigniter project
.
编辑
我使用以下代码创建了一个新脚本.
<?php
var_dump($_POST);
echo $_POST['UserName'];
echo $_POST['FacebookID'];
echo $_POST['Email'];
echo "********************************";
?>
Run Code Online (Sandbox Code Playgroud)
这是说undefined index
.可能是什么问题 ?请帮忙.它工作正常$_GET
我正在尝试从网址加载图片的尺寸.到目前为止,我已尝试使用,GraphicsMagick
但它给了我ENOENT
错误.
这是我写的代码到目前为止.
var gm = require('gm');
...
gm(img.attribs.src).size(function (err, size) {
if (!err) {
if( size.width>200 && size.height>200)
{
console.log('Save this image');
}
}
});
Run Code Online (Sandbox Code Playgroud)
哪里img.attribs.src
包含url source path
图像.
更新
的价值 img.attribs.src
http://rack.1.mshcdn.com/assets/header_logo.v2-30574d105ad07318345ec8f1a85a3efa.png
我有一个项目,必须将不同的文件导入Blender。我只是搅拌器的入门者,它是python API。我正在寻找一种使用python脚本将.dae文件导入Blender的方法。到目前为止,我一直未能在python中找到用于Blender的导入模块。
谁能指出我正确的方向?
我是cython的新手。
我有以下目录结构。
cython_program/
cython_program/helloworld.py
cython_program/lib/printname.py
Run Code Online (Sandbox Code Playgroud)
helloworld.py:
import lib.printname as name
def printname():
name.myname()
Run Code Online (Sandbox Code Playgroud)
printname.py:
def myname():
print("this is my name")
Run Code Online (Sandbox Code Playgroud)
setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [
Extension("helloworld", ["helloworld.py"]),
Extension("mod", ["./lib/printname.py"]),
]
setup(
name = 'My Program',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是当我python setup.py build_ext --inplace
在cython_program
目录中使用编译程序时。它确实可以成功编译程序,并printname.c
在lib文件夹中生成一个文件。
但是,当我将printname.py和helloworld.py移到单独的文件夹中时,请确保我的cython编译代码正在运行。它给了我以下错误 ImportError: No module named lib.printname
。
为什么不同时用主helloworld.py
文件编译模块(lib.printname)?
注意:如果我将helloworld.py和printname.py都保留在同一文件夹中,则可以正常工作。
提前致谢。
android ×2
angular ×2
php ×2
python ×2
unit-testing ×2
blender ×1
codeigniter ×1
cython ×1
cythonize ×1
google-maps ×1
jasmine ×1
java ×1
ngrx ×1
node.js ×1
php-include ×1
post ×1